Simple GitHub Action to get the previous workflow run's conclusion/status on the current branch.
Inspired by Travis CI's on_success: change notification feature — useful for sending alerts only when the build status changes.
- Secret GitHub API token used for API requests.
- Default:
${{ github.token }}— works automatically, no need to pass it explicitly unless you need a custom token.
- Conclusion of the last completed workflow run. Possible values:
success,failure,cancelled,skipped,timed_out,action_required,neutral,stalenull— if there is no previous run
See GitHub docs for more details on conclusion values.
jobs:
your-job:
runs-on: ubuntu-latest
steps:
- name: Get previous workflow status
uses: Mercymeilya/last-workflow-status@v0
id: last_status
- name: Any action
run: style-check.sh
- name: Build fixed slack message
uses: rtCamp/action-slack-notify@v2.1.3
if: ${{ success() && steps.last_status.outputs.last_status == 'failure' }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'Style check fixed now!'