A no-config GitHub action that notifies slack of the status of your GitHub actions
We currently support:
pull_request
release
push
(tags, commits)schedule
create (branch)
delete (branch)
All event messages will have these elements:
- Build Indicator - Will be green for successful, red for failed, yellow for cancelled
- Author Github Profile and User - This is also a link their profile page
- Workflow Name - Also a link to the run
- Repository Name - Also a link
- Timestamp
- Commit Hash - Also a link showing the changes between the base and ref
- Pull Request Number and Title - Also a link to the Pull Request
- Commit Hash - Also a link showing all changes in the release
- Release Title - Also a link to the release and notes. If the release doesn't have a title the tag name will be used.
- Commit Hash - Also a link showing all changes since this tag and master
- Tag name - Also a link to the tag
- Commit Hash - Also a link showing combined changes of all commits for the push
- Head Commit name - Name of last commit in the batch (can push multiple commits). Also a link to that commit.
Note that Schedule does not have the user as there's no commit information.
- Branch Name - Also link to the branch.
- Branch Name
You can use this action after any other action, however I recommend you put it as the last one. Here is an example setup of this action for a pull request:
- Create a
.github/workflows/test.yml
file in your GitHub repo. - Add the following code to the
test.yml
file.
name: Test
on:
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- run: npm install
- run: npm test
- uses: iRoachie/slack-github-actions@v2.3.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
if: ${{ always() }}
- Create
SLACK_WEBHOOK_URL
secret using GitHub Action's Secret. You can generate a Slack incoming webhook token from here.
Here's an example with jobs that run in parallel.
It does a few things:
- Lets us know when a status check didn't succeed
- If all jobs were successful, we'll send a message at the end
Note that the status variable is omitted here.
name: Test
on:
pull_request:
branches:
- master
jobs:
test:
name: Jest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn test
lint:
name: Eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
notify:
Name: Slack
needs: [test, lint] # We only check after the others jobs have run
if: always() # Always runs even if one of the builds fails
runs-on: ubuntu-latest
steps:
- uses: iRoachie/slack-github-actions@v2.3.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}