Skip to content

Add needs: syntax example using always() condition #1307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions content/actions/reference/workflow-syntax-for-github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ The name of the job displayed on {% data variables.product.prodname_dotcom %}.

### `jobs.<job_id>.needs`

Identifies any jobs that must complete successfully before this job will run. It can be a string or array of strings. If a job fails, all jobs that need it are skipped unless the jobs use a conditional statement that causes the job to continue.
Identifies any jobs that must complete successfully before this job will run. It can be a string or array of strings. If a job fails, all jobs that need it are skipped unless the jobs use a conditional expression that causes the job to continue.

#### Example
#### Example requiring dependent jobs to be successful

```yaml
jobs:
Expand All @@ -270,6 +270,20 @@ The jobs in this example run sequentially:
2. `job2`
3. `job3`

#### Example not requiring dependent jobs to be successful
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll raise a docs issue for all the titles in this guide, so that we can move them to an "Example: verb" convention

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #2063 👍


```yaml
jobs:
job1:
job2:
needs: job1
job3:
if: always()
needs: [job1, job2]
```

In this example, `job3` uses the `always()` conditional expression so that it always runs after `job1` and `job2` have completed, regardless of whether they were successful. For more information, see "[Context and expression syntax](/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions)."

### `jobs.<job_id>.runs-on`

**Required** The type of machine to run the job on. The machine can be either a {% data variables.product.prodname_dotcom %}-hosted runner or a self-hosted runner.
Expand Down