Skip to content

Commit 47e5220

Browse files
committed
Notify Slack when deploy is cancelled manually
1 parent 6b70bf4 commit 47e5220

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,43 @@ jobs:
649649
with:
650650
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
651651

652+
postSlackMessageOnCancellation:
653+
name: Post a Slack message when the deploy is cancelled manually
654+
runs-on: blacksmith-2vcpu-ubuntu-2404
655+
if: ${{ cancelled() }}
656+
needs: [androidBuild, androidUploadGooglePlay, androidSubmit, iosBuild, iosUploadTestflight, iosSubmit, webBuild, webDeploy]
657+
steps:
658+
- name: Check whether a newer deploy run exists
659+
id: check
660+
run: |
661+
# If a newer run exists, the cherry-pick workflow already announced this. Skip to avoid double-posting.
662+
LATEST=$(gh api \
663+
"repos/${{ github.repository }}/actions/workflows/deploy.yml/runs?branch=${{ github.ref_name }}&per_page=1" \
664+
--jq '.workflow_runs[0].id')
665+
if [ "$LATEST" != "${{ github.run_id }}" ]; then
666+
echo "SKIP=true" >> "$GITHUB_OUTPUT"
667+
fi
668+
env:
669+
GITHUB_TOKEN: ${{ github.token }}
670+
671+
- name: Post Slack message on manual cancellation
672+
if: ${{ steps.check.outputs.SKIP != 'true' }}
673+
# v3
674+
uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e
675+
with:
676+
status: custom
677+
custom_payload: |
678+
{
679+
channel: '#deployer',
680+
attachments: [{
681+
color: 'warning',
682+
text: `⚠️ ${{ github.ref == 'refs/heads/production' && 'Production' || 'Staging' }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|deploy> cancelled manually`
683+
}]
684+
}
685+
env:
686+
GITHUB_TOKEN: ${{ github.token }}
687+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
688+
652689
checkDeploymentSuccess:
653690
runs-on: blacksmith-2vcpu-ubuntu-2404
654691
outputs:

0 commit comments

Comments
 (0)