So in a Jenkins job, it has the usual post-run job status of "pass", "fail" and some others. There's also a fixed status; Which I think is if a job passes after it has failed before. Is there anything like this for Actions? I couldn't see anything in the docs, I'd like to have my job post to slack only if something has passed after a failure, but not every success
The Jenkins post
condition fixed
applies if the current run is successful and the previous run failed or was unstable.
GitHub Actions does not have a post
equivalent. A normal action can be used, so you have to define an job/step for this activity - for a functional equivalent.
You use needs
to define the previous jobs it depends on. You use if
to define the build state conditions.
From the context availability, which describes what data is available in the if condition, you can see that success
is available.
However, for the last build status, looking at both jobs.<job_id>.if
and jobs.<job_id>.steps.if
, no special function nor context with applicable property exists. So the previous workflow result status has to be queried for via request.
You can do this with your own defined jobs and steps, or make use of a Marketplace action like Get status of last workflow.
Their example includes a step that matches your condition case too:
if: ${{ success() && steps.last_status.outputs.last_status == 'failure' }}
in context:
- name: Build fixed slack message
uses: rtCamp/[email protected]
if: ${{ success() && steps.last_status.outputs.last_status == 'failure' }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'Style check fixed now!'