Merge pull request #521 from projects200/feat/feed/create-feed-content #215
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: DEV SERVER CI/CD | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| workflow_dispatch: | |
| jobs: | |
| backend-CI: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "21" | |
| distribution: "corretto" | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Configure AWS credentials | |
| if: ${{ github.ref == 'refs/heads/develop'}} | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| # 1. 애플리케이션 속성 파일 설정 | |
| - name: Configure Application Properties | |
| run: | | |
| mkdir -p src/main/resources/ | |
| echo ${{ secrets.APPLICATION_DEV_YML }} | base64 -d > src/main/resources/application-dev.yml | |
| shell: bash | |
| # 2. Firebase Admin SDK 설정 | |
| - name: Configure Firebase Admin SDK | |
| run: | | |
| mkdir -p src/main/resources/firebase | |
| echo ${{ secrets.DEV_FIREBASE_ADMIN_SDK_JSON }} | base64 -d > src/main/resources/firebase/undabang-firebase-adminsdk.json | |
| shell: bash | |
| # 3. 모든 설정이 끝난 후 빌드 실행 | |
| - name: Build Gradle | |
| run: | | |
| chmod +x gradlew | |
| ./gradlew build -Dspring.profiles.active=dev-docs | |
| shell: bash | |
| - name: Build and push image to Amazon ECR | |
| if: ${{ github.ref == 'refs/heads/develop' }} | |
| env: | |
| REGISTRY: 825773631552.dkr.ecr.ap-northeast-2.amazonaws.com | |
| REPOSITORY: undabang/dev-server-repository | |
| IMAGE_TAG: latest | |
| run: | | |
| aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $REGISTRY | |
| cp build/libs/*.jar deploy-dev/ | |
| cd deploy-dev | |
| docker build -t $REPOSITORY . | |
| rm *.jar | |
| docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REPOSITORY:$IMAGE_TAG | |
| docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG | |
| - name: Upload build file to S3 and trigger CodeDeploy | |
| if: ${{ github.ref == 'refs/heads/develop' }} | |
| run: | | |
| mkdir -p deploy && cp -r deploy-dev/* deploy/ | |
| zip -r deploy.zip deploy | |
| aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_DEPLOY_DEV_BUCKET_NAME }}/deploy.zip | |
| aws deploy create-deployment \ | |
| --application-name ${{ secrets.AWS_CODEDEPLOY_DEV_APP_NAME }} \ | |
| --deployment-config-name CodeDeployDefault.AllAtOnce \ | |
| --deployment-group-name ${{ secrets.AWS_CODEDEPLOY_DEV_GROUP_NAME }} \ | |
| --file-exists-behavior OVERWRITE \ | |
| --s3-location bucket=${{ secrets.AWS_S3_DEPLOY_DEV_BUCKET_NAME }},bundleType=zip,key=deploy.zip |