From 35d9a8c02b4c6f1ef7434a0a4675eb52e95657a9 Mon Sep 17 00:00:00 2001 From: Gyumin Hwangbo Date: Sat, 24 Feb 2024 17:48:27 +0900 Subject: [PATCH 1/4] fix: edit github script --- .github/workflows/pr-alert.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-alert.yaml b/.github/workflows/pr-alert.yaml index 648df95..6d1570c 100644 --- a/.github/workflows/pr-alert.yaml +++ b/.github/workflows/pr-alert.yaml @@ -22,14 +22,14 @@ jobs: let message; if (status === 'success') { - message = `✅ Workflow ${workflowName} succeeded ✅\n- [Show details](https://github.com/owner/repo/actions/runs/${runId})`; + message = `✅ Workflow ${workflowName} succeeded ✅\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${runId})`; } else { - message = `❌ Workflow ${workflowName} failed ❌\n- [Show details](https://github.com/owner/repo/actions/runs/${runId})`; + message = `❌ Workflow ${workflowName} failed ❌\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${runId})`; } github.rest.issues.createComment({ issue_number: ${{ github.event.workflow_run.head_repository.default_branch }}, - owner: 'owner', - repo: 'repo', + owner: 'ghkdqhrbals', + repo: 'spring-chatting-server', body: message - }) + }); \ No newline at end of file From 57fd45e6b91e548a1823ce628e9545a9a0b2b794 Mon Sep 17 00:00:00 2001 From: Gyumin Hwangbo Date: Sat, 24 Feb 2024 17:54:13 +0900 Subject: [PATCH 2/4] fix: change id field --- .github/workflows/deploy.yaml | 2 +- .github/workflows/pr-alert.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index eb15300..a801c4d 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -183,7 +183,7 @@ jobs: - name: Set up gcloud cli uses: google-github-actions/setup-gcloud@v2 - - id: Set GKE cluster context + - name: Set GKE cluster context uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: cluster diff --git a/.github/workflows/pr-alert.yaml b/.github/workflows/pr-alert.yaml index 6d1570c..002155e 100644 --- a/.github/workflows/pr-alert.yaml +++ b/.github/workflows/pr-alert.yaml @@ -3,8 +3,7 @@ name: Notify PR Completion on: workflow_run: workflows: ["Deployment"] - types: - - completed + types: [completed, failed] jobs: notify: From bed9fc1fe139b1db242ffb2b4bc304c734fa704e Mon Sep 17 00:00:00 2001 From: Gyumin Hwangbo Date: Sat, 24 Feb 2024 18:01:18 +0900 Subject: [PATCH 3/4] fix: change workflow_run types and other --- .github/workflows/deploy.yaml | 4 +-- .github/workflows/pr-alert.yaml | 45 +++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a801c4d..72848a0 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -223,7 +223,7 @@ jobs: echo "::set-output name=duration::${MINUTES}m ${SECONDS}s" pushSlack: - needs: [ pushImageToEcr, pushNewTag, DeployToEKSCluster ] + needs: [ pushImageToEcr, pushNewTag, DeployToGKECluster ] if: always() name: 📢 Slack Alert runs-on: ubuntu-latest @@ -251,7 +251,7 @@ jobs: }, { "title": "Deployment Workflow Status", - "value": ":label: Push New Tag\t\t\tDuration: ${{ needs.pushNewTag.outputs.DURATION }} sec\t\tResult: ${{ needs.pushNewTag.result }}\n:whale: Push Image To ECR\tDuration: ${{ needs.pushImageToEcr.outputs.DURATION }} sec\t\tResult: ${{ needs.pushImageToEcr.result }}\n:rocket: Deploy To EKS\t\t\tDuration: ${{ needs.DeployToEKSCluster.outputs.DURATION }} sec\t\tResult: ${{ needs.DeployToEKSCluster.result }}", + "value": ":label: Push New Tag\t\t\tDuration: ${{ needs.pushNewTag.outputs.DURATION }} sec\t\tResult: ${{ needs.pushNewTag.result }}\n:whale: Push Image To ECR\tDuration: ${{ needs.pushImageToEcr.outputs.DURATION }} sec\t\tResult: ${{ needs.pushImageToEcr.result }}\n:rocket: Deploy To GKE\t\t\tDuration: ${{ needs.DeployToEKSCluster.outputs.DURATION }} sec\t\tResult: ${{ needs.DeployToEKSCluster.result }}", "short": false } ] diff --git a/.github/workflows/pr-alert.yaml b/.github/workflows/pr-alert.yaml index 002155e..3e1d7ac 100644 --- a/.github/workflows/pr-alert.yaml +++ b/.github/workflows/pr-alert.yaml @@ -1,34 +1,41 @@ name: Notify PR Completion + on: workflow_run: - workflows: ["Deployment"] - types: [completed, failed] + workflows: [Deployment] + types: [completed] jobs: - notify: + on-success: runs-on: ubuntu-latest - if: always() + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - name: Notify on Workflow Completion + - name: Notify current workflow is succeed uses: actions/github-script@v6 + if: success() + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: ${{ github.event.pull_request.number }}, + owner: 'ghkdqhrbals', + repo: 'spring-chatting-server', + body: '✅ Build & Test workflow succeed ✅\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${{ github.run_id }})' + }) + on-failure: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - name: Notify current workflow is failed + uses: actions/github-script@v6 + if: failure() with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const status = '${{ github.event.workflow_run.conclusion }}'; - const workflowName = '${{ github.event.workflow.name }}'; - const runId = '${{ github.event.workflow_run.id }}'; - - let message; - if (status === 'success') { - message = `✅ Workflow ${workflowName} succeeded ✅\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${runId})`; - } else { - message = `❌ Workflow ${workflowName} failed ❌\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${runId})`; - } - github.rest.issues.createComment({ - issue_number: ${{ github.event.workflow_run.head_repository.default_branch }}, + issue_number: ${{ github.event.pull_request.number }}, owner: 'ghkdqhrbals', repo: 'spring-chatting-server', - body: message - }); \ No newline at end of file + body: '❌ Build & Test workflow failed ❌\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${{ github.run_id }})' + }) From f2c3e4cd06d3421b1b5377c85c4626edfe08a4f5 Mon Sep 17 00:00:00 2001 From: Gyumin Hwangbo Date: Sat, 24 Feb 2024 18:12:53 +0900 Subject: [PATCH 4/4] fix: change region of gke --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 72848a0..4a8ce94 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -187,7 +187,7 @@ jobs: uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: cluster - location: us-central1-a + location: asia-east1-a - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1