-
Notifications
You must be signed in to change notification settings - Fork 66.4k
Description
Code of Conduct
- I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif
https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
What part(s) of the article would you like to see updated?
There is potential confusion when jobs are skipped in workflows with multiple jobs and with status checks.
If a run contains a series of jobs that need each other, a failure or skip applies to all jobs in the dependency chain from the point of failure or skip onwards.
This is from
| Use `jobs.<job_id>.needs` to identify any jobs that must complete successfully before this job will run. It can be a string or array of strings. If a job fails or is skipped, all jobs that need it are skipped unless the jobs use a conditional expression that causes the job to continue. If a run contains a series of jobs that need each other, a failure or skip applies to all jobs in the dependency chain from the point of failure or skip onwards. |
This takes precedence over https://docs.github.com/en/actions/learn-github-actions/expressions#success. While this isn't wrong, it should be called out.
needs.<job_id>.result is particularly interesting because it can be used in job.<job_id>.if. However, needs.<job_id>.result == 'skipped' will not matter because "a failure or skip applies to all jobs in the dependency chain from the point of failure or skip onwards."
There's additional nuance needed with https://docs.github.com/en/actions/learn-github-actions/expressions#always. While always() always runs, it's needed to check conditionals on jobs in a dependency chain that contain a skipped job.
Additional information
Multiple scenarios were set up and tested in https://github.com/Ubersmake/try-github-actions/actions/runs/6355991752 to try running jobs when a previous job was skipped.
Maintainer note / Docs plan
To update the docs for this issue, we need to do the following.
-
In https://docs.github.com/en/actions/learn-github-actions/expressions#success, update the description to say:
Returns `true` when all previous steps have succeeded. -
In this reusable, add a sentence at the end of line 1 that says something similar to:
If you would like a job to run even if a job it is dependent on did not succeed, use the `always()` conditional expression in `jobs.<job_id>.if`.