Skip to content

Commit

Permalink
improve slack alerts for cd
Browse files Browse the repository at this point in the history
  • Loading branch information
shrunyan committed Mar 19, 2024
1 parent cc06e02 commit 9103360
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions .github/workflows/cd-dev-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,38 +59,10 @@ jobs:
SLACK_TITLE: Successfully Deployed manager-ui to Dev
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
cancel_workflow_if_dev_deploy_failed:
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- deploy_to_dev
steps:
- name: Post Failed Dev Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: "#FF0000"
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: "PR merge by ${{ github.actor }} has failed to deploy to dev."
SLACK_TITLE: Dev Deployment Failed for manager-ui
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Cancel current workflow run
uses: actions/github-script@v4
with:
script: |
github.actions.cancelWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
})
deploy_to_stage:
runs-on: ubuntu-latest
env:
ENV: "stage"
needs:
- deploy_to_dev

steps:
# This Clean step simply checks if there's already a workflow running from the last
Expand Down Expand Up @@ -138,20 +110,36 @@ jobs:
SLACK_TITLE: Successfully Deployed manager-ui to Stage
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
post_failed_stage_deploy_notification_to_slack:

failed_deploy_notification_to_slack:
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- deploy_to_stage
needs: [deploy_to_dev, deploy_to_stage]
steps:
- name: Post Failed Staging Deploy Notification To Slack
- name: Failed Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_CHANNEL: code-deploy
SLACK_COLOR: "#FF0000"
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: "PR merge by ${{ github.actor }} failed to deploy."
SLACK_TITLE: Deployment Failed for manager-ui
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

success_deploy_notification_to_slack:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: [deploy_to_stage]
steps:
- name: Success Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: code-deploy
SLACK_COLOR: "#FF0000"
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: "PR merge by ${{ github.actor }} has failed to deploy to staging."
SLACK_TITLE: Staging Deployment Failed for manager-ui
SLACK_MESSAGE: "PR merge by ${{ github.actor }} has been deployed to stage."
SLACK_TITLE: Stage Deployment for manager-ui
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

Expand All @@ -166,7 +154,7 @@ jobs:
- name: Create Beta Release PR
uses: peter-evans/create-pull-request@v6
with:
branch: dev
base: beta
branch: beta
# base: dev
title: beta
# labels:

0 comments on commit 9103360

Please sign in to comment.