Github action that keeps track and retrieves previous workflow runs status for the same workflow on the same branch. According to current and previous runs status, it will send a notification to a Slack channel using an Incoming webhook app.
At the end of a workflow, on success() and on failure(), call this action with the current status as a parameter (success/failure).
This action will first check the previous workflow status and will send a Slack notification according to the current workflow status.
Status is retrieved from cache if the current workflow has already run previously (from re-run all jobs
button for example).
If it's the first time this workflow runs, this action will retrieve previous workflow status on the same branch with gh
cli using provided github-token
.
It'll compare last/current workflow status and will send a notification to Slack if:
- Current status is
failure
and it's the first time this workflow runs for the current branch. - Current status is
failure
and previous run status wassuccess
. - Current status is
success
and previous run status wasfailure
.
It'll not send a notification to Slack if:
- Current status is
success
and previous run status wassuccess
. - Current status is
success
and it's the first run. - Current status is
failure
and previous run status wasfailure
.
You need to define this secret: YOUR_SLACK_WEBHOOK: Webhook URL from Slack Incoming Webhook application
- uses: reside-eng/workflow-status-notification-action@v1
with:
# Status of the current run
#
# Default: failure
# Required: true
current-status: ''
# Webhook URL with token for notifications
#
# Required: true
slack-webhook: ''
# Type of notification (on-state-change, release)
#
# Default: on-state-change
notify-type: ''
# Status of the current run
#
# Required: true
github-token: ''
name: Build
on:
pull_request:
branches:
- main
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# Your steps...
notification:
if: always()
name: notification
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: technote-space/workflow-conclusion-action@v2.0.1
- uses: reside-eng/workflow-status-slack-notification@v1.0.0
with:
current-status: ${{ env.WORKFLOW_CONCLUSION }}
slack-webhook: ${{ secrets.YOUR_SLACK_WEBHOOK }}
github-token: ${{ secrets.GITHUB_TOKEN }}
Please install gh CLI: https://github.com/cli/cli#installation
In order to run the jest tests, you'll need to configure authentication using your gh CLI:
gh auth refresh
You'll be prompted with a one-time code, copy this one.
Then click on enter, a web page will open in your browser.
Paste the code previously copied.
Click on Authorize github
You're all set !
The scripts and documentation in this project are released under the MIT License.
- Why Node 16?
This is the maximum version runtime supported by Github Actions