Skip to content

Commit cecda2a

Browse files
Add needs: syntax example using always() condition (#1307)
Co-authored-by: Lucas Costi <[email protected]>
1 parent c25bd6b commit cecda2a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

content/actions/reference/workflow-syntax-for-github-actions.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ The name of the job displayed on {% data variables.product.prodname_dotcom %}.
249249

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

252-
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.
252+
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.
253253

254-
#### Example
254+
#### Example requiring dependent jobs to be successful
255255

256256
```yaml
257257
jobs:
@@ -270,6 +270,20 @@ The jobs in this example run sequentially:
270270
2. `job2`
271271
3. `job3`
272272

273+
#### Example not requiring dependent jobs to be successful
274+
275+
```yaml
276+
jobs:
277+
job1:
278+
job2:
279+
needs: job1
280+
job3:
281+
if: always()
282+
needs: [job1, job2]
283+
```
284+
285+
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)."
286+
273287
### `jobs.<job_id>.runs-on`
274288

275289
**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.

0 commit comments

Comments
 (0)