Skip to content

Clarify expressions and provide examples for workflows with skipped jobs #28762

@Ubersmake

Description

@Ubersmake

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.

  1. 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.
    
  2. 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`.
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamhelp wantedAnyone is welcome to open a pull request to fix this issuepumpkin-spiceSpecifically tracked Hacktoberfest issue - internal purposes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions