Skip to content

Commit

Permalink
Merge pull request #407 from ghkdqhrbals/feat/eks-to-gke
Browse files Browse the repository at this point in the history
fix: edit github script
  • Loading branch information
ghkdqhrbals authored Feb 24, 2024
2 parents e877685 + f2c3e4c commit a70a843
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ 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
location: us-central1-a
location: asia-east1-a

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
]
Expand Down
48 changes: 27 additions & 21 deletions .github/workflows/pr-alert.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
name: Notify PR Completion


on:
workflow_run:
workflows: ["Deployment"]
types:
- completed
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/owner/repo/actions/runs/${runId})`;
} else {
message = `❌ Workflow ${workflowName} failed ❌\n- [Show details](https://github.com/owner/repo/actions/runs/${runId})`;
}
github.rest.issues.createComment({
issue_number: ${{ github.event.workflow_run.head_repository.default_branch }},
owner: 'owner',
repo: 'repo',
body: message
issue_number: ${{ github.event.pull_request.number }},
owner: 'ghkdqhrbals',
repo: 'spring-chatting-server',
body: '❌ Build & Test workflow failed ❌\n- [Show details](https://github.com/ghkdqhrbals/spring-chatting-server/actions/runs/${{ github.run_id }})'
})

0 comments on commit a70a843

Please sign in to comment.