Skip to content

Conversation

@winem
Copy link
Contributor

@winem winem commented Jan 4, 2021

Happy new year everyone,

this PR sends a Slack notification if a GH Action run on the master branch fails. It uses the new Slack Bot API which is the currently recommended way to integrate your apps into Slack (incoming webhooks are "legacy" now).

It relies on 2 GitHub Action services:
1st) https://github.com/technote-space/workflow-conclusion-action - this one is needed to provide a single status for all the workflows executed so far (otherwise we would get a slack notification for ci-checks, ci-compile, ci-packs-tests and ci-unit which is unneeded noise). The workflow conclusion action creates an environment variable WORKFLOW_CONCLUSION which is success if all the jobs were successful or failure if any of them failed
2nd) https://github.com/voxmedia/github-action-slack-notify-build - this is the container that actually passes the message to slack

The notification is only triggered for master builds that failed and it will look like this:
Selection_199

The link ci leads directly to the failed execution of the Github Actions.
This PR has 2 external dependencies:
1st: A Slack Bot:

  • Create the Slack App as described here: https://api.slack.com/apps and select the stackstorm-development workspace.
  • Grant the following scopes to the bot: channels:read, chat:write and groups:read
  • Install the bot to the workspace and confirm with Allow
  • Go to OAuth & Permissions and copy the OAuth Tokens for Your Team token

2nd: Create a Github repository secret called SLACK_BOT_TOKEN:
Go to the Stackstorm/st2 repository -> Settings -> Secrets -> New Repository Secret -> Set the name to SLACK_BOT_TOKEN and the value to the bot token created in the step above
The token must start with xoxb-

winem added 26 commits December 26, 2020 21:26
… lint checks again" to fix them again

This reverts commit b7cfb45.
@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines. Very easy to review. label Jan 4, 2021
@arm4b arm4b added this to the 3.4.0 milestone Jan 14, 2021
# this step creates an environment variable WORKFLOW_CONCLUSION and is the most reliable way to check the status of previous jobs
uses: technote-space/workflow-conclusion-action@v2
- name: CI Run Failure Slack Notification
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' && github.ref == 'refs/heads/master' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work 👍

Additional thanks for the instructions and verifying the whole setup!

Upd: finished setting up SLACK_BOT_TOKEN for Github.

@arm4b
Copy link
Member

arm4b commented Jan 14, 2021

FYI @nmaludy ^^ as it's related to your #5098

@arm4b arm4b requested review from blag and nmaludy January 14, 2021 21:04
@arm4b arm4b merged commit 3c530ad into StackStorm:feature/github-actions Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure: ci/cd size/S PR that changes 10-29 lines. Very easy to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants