vatu-team / workflows

Vatu's reusable workflows for development work.
Apache License 2.0
0 stars 0 forks source link

Slack notification if any actions fail #6

Open dmpinder opened 2 years ago

michaelbragg commented 1 year ago

For future reference: https://stackoverflow.com/questions/58858429/how-to-run-a-github-actions-step-even-if-the-previous-step-fails-while-still-f#answers

michaelbragg commented 8 months ago

Have added to Demo repo and outputting to updates channel (as that is where the app is installed).

Screenshot 2024-03-11 at 16 31 41

Which workflows do we want this on @dmpinder?

      - name: "Failure notification."
        if: ${{ failure() }}
        id: 'slack'
        uses: 'slackapi/slack-github-action@v1.25.0'
        with:
          channel-id: 'updates'
          payload: |
            {
              "text": "${{ github.workflow }} workflow failed for ${{ github.event.repository.name }}",
              "blocks": [
                {
                  "type": "section",
                  "text": {
                    "type": "mrkdwn",
                    "text": "${{ github.workflow }} workflow failed for ${{ github.event.repository.name }}.\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View>"
                  }
                }
              ]
            }
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
dmpinder commented 8 months ago

Looks good!

Failure notifications on build and static analysis would be ideal, thanks.

michaelbragg commented 8 months ago

Have added both to the demo repo if you want to check them out.

dmpinder commented 2 weeks ago

Picking this up again, not sure how to test this, or if I need to test it? If you're happy it's working lets roll it out on the other repos.