notify main failure #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: notify main failure | |
| # Fires only when the verify workflow completes on main (push events). | |
| # PR branch builds never match the branches: [main] filter. | |
| on: | |
| workflow_run: | |
| workflows: ["verify"] | |
| types: [completed] | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify: | |
| if: github.event.workflow_run.conclusion == 'failure' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Notify Slack | |
| continue-on-error: true | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.OMOQ_SLACK_WEBHOOK_URL }} | |
| run: | | |
| SHORT="${{ github.event.workflow_run.head_sha }}" | |
| SHORT="${SHORT:0:7}" | |
| RUN_URL="${{ github.event.workflow_run.html_url }}" | |
| TEXT=":x: *${{ github.repository }}* \`main\` \`${SHORT}\` — verify failed: <${RUN_URL}|#${{ github.event.workflow_run.run_number }}>" | |
| curl -s -X POST "$SLACK_WEBHOOK_URL" \ | |
| -H "Content-Type: application/json" \ | |
| --data "{\"text\": \"${TEXT}\"}" | |
| - name: Notify email | |
| continue-on-error: true | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.OMOQ_AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.OMOQ_AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: us-east-1 | |
| run: | | |
| SHORT="${{ github.event.workflow_run.head_sha }}" | |
| SHORT="${SHORT:0:7}" | |
| RUN_URL="${{ github.event.workflow_run.html_url }}" | |
| SUBJECT="[o-rly] verify failed on main ${SHORT}" | |
| BODY="Verify failed on main.\n\nCommit: ${{ github.event.workflow_run.head_sha }}\nRun: ${RUN_URL}" | |
| aws ses send-email \ | |
| --from "noreply@ci.openmoq.org" \ | |
| --destination '{"ToAddresses":["github-notifications@openmoq.org"]}' \ | |
| --message "{ | |
| \"Subject\": {\"Data\": \"${SUBJECT}\"}, | |
| \"Body\": {\"Text\": {\"Data\": \"${BODY}\"}} | |
| }" |