A no-config GitHub action that notifies slack of the status of your GitHub actions
MIT License
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:
Note that Schedule does not have the user as there's no commit information.
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:
.github/workflows/test.yml
file in your GitHub repo.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/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
if: ${{ always() }}
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:
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/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}