From 552e8387f58a2450ef5579409c60c815cc18ffb8 Mon Sep 17 00:00:00 2001 From: San Kim Date: Sun, 22 Sep 2024 20:48:30 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Deploy=20=EC=9B=8C=ED=81=AC?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=9B=B9=ED=9B=85=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-dev.yaml | 90 ++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd-dev.yaml b/.github/workflows/cd-dev.yaml index e5a0dca..c51eb4b 100644 --- a/.github/workflows/cd-dev.yaml +++ b/.github/workflows/cd-dev.yaml @@ -16,6 +16,7 @@ env: ECR_REPOSITORY: threedays-app EB_APPLICATION_NAME: threedays-dev EB_ENVIRONMENT_NAME: threedays-dev-env + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} jobs: deploy: @@ -26,6 +27,33 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Send Deployment Start Webhook + run: | + curl -H "Content-Type: application/json" -X POST -d '{ + "content": "배포가 시작되었습니다.", + "embeds": [{ + "title": "배포 시작", + "color": 16776960, + "fields": [ + { + "name": "버전", + "value": "${{ github.event.inputs.version || github.event.client_payload.version || 'latest' }}", + "inline": true + }, + { + "name": "환경", + "value": "'"${EB_ENVIRONMENT_NAME}"'", + "inline": true + }, + { + "name": "배포자", + "value": "'"${GITHUB_ACTOR}"'", + "inline": true + } + ] + }] + }' ${{ env.DISCORD_WEBHOOK }} + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: @@ -117,6 +145,7 @@ jobs: zip -r deploy.zip Dockerrun.aws.json .ebextensions - name: Deploy to Elastic Beanstalk + id: deploy uses: einaregilsson/beanstalk-deploy@v22 with: aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -128,5 +157,62 @@ jobs: deployment_package: deploy.zip use_existing_version_if_available: false - - name: Deployment result - run: echo "Deployed version ${{ steps.determine-version.outputs.VERSION }} to Elastic Beanstalk environment ${{ env.EB_ENVIRONMENT_NAME }}" + - name: Send Deployment Success Webhook + if: success() + env: + VERSION: ${{ steps.determine-version.outputs.VERSION }} + run: | + curl -H "Content-Type: application/json" -X POST -d '{ + "content": "배포가 성공적으로 완료되었습니다!", + "embeds": [{ + "title": "배포 성공", + "color": 65280, + "fields": [ + { + "name": "버전", + "value": "'"${VERSION}"'", + "inline": true + }, + { + "name": "환경", + "value": "'"${EB_ENVIRONMENT_NAME}"'", + "inline": true + }, + { + "name": "배포자", + "value": "'"${GITHUB_ACTOR}"'", + "inline": true + } + ] + }] + }' ${{ env.DISCORD_WEBHOOK }} + + - name: Send Deployment Failure Webhook + if: failure() + env: + VERSION: ${{ steps.determine-version.outputs.VERSION }} + run: | + curl -H "Content-Type: application/json" -X POST -d '{ + "content": "배포 중 오류가 발생했습니다.", + "embeds": [{ + "title": "배포 실패", + "color": 16711680, + "fields": [ + { + "name": "버전", + "value": "'"${VERSION}"'", + "inline": true + }, + { + "name": "환경", + "value": "'"${EB_ENVIRONMENT_NAME}"'", + "inline": true + }, + { + "name": "배포자", + "value": "'"${GITHUB_ACTOR}"'", + "inline": true + } + ] + }] + }' ${{ env.DISCORD_WEBHOOK }}