From 107e0bf8787dc2d4bfa264f5d3ca5289c645071b Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 10:26:28 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20CI/CD=20yml=20=ED=95=A9=EC=B9=98?= =?UTF-8?q?=EA=B8=B0(=EC=9E=84=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index d917a881..7c3c3c6d 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -51,4 +51,41 @@ jobs: - name: Tear down Docker Compose if: always() - run: docker-compose down \ No newline at end of file + run: docker-compose down + + # DI + - name: Set Yaml + uses: microsoft/variable-substitution@v1 + with: + files: ./src/main/resources/application-prod.yml + env: + spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} + spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} + spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }} + spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }} + spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }} + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Make Zip file + run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh + shell: bash + + - name: AWS credential setting + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{secrets.AWS_KJH_REGION}} + aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}} + aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} + + - name: Upload to S3 + run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + + - name: EC2 Deploy + run: aws deploy create-deployment + --application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}} + --deployment-config-name CodeDeployDefault.AllAtOnce + --deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}} + --s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip \ No newline at end of file