Skip to content

Commit

Permalink
ci: notify Slack when the deploy workflow is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
ahal committed Jul 9, 2024
1 parent 90b8a90 commit 45e8fbf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,28 @@ jobs:
run: pip install -r requirements/base.txt
- name: Deploy environment
run: tc-admin apply --environment ${{matrix.environment}}

notify:
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: [check, apply]
strategy:
matrix:
environment: ["staging", "firefoxci"]
steps:
- name: Notify Slack
if: always()
run: |
WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
SLACK_MESSAGE="*${{ github.workflow }} ${{ github.repository }}* (<${WORKFLOW_URL}|View Workflow>)"
for JOB_NAME in ${!needs.*.result}; do
JOB_STATUS="${{ needs[$JOB_NAME].result }}"
if [ $"JOB_STATUS" == "success" ]; then
SLACK_MESSAGE="${SLACK_MESSAGE}\n:white_check_mark: *${JOB_NAME}*
else
SLACK_MESSAGE="${SLACK_MESSAGE}\n:x: *${JOB_NAME}*
fi
done
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${SLACK_MESSAGE}\"}" ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit 45e8fbf

Please sign in to comment.