Skip to content

Commit 994474d

Browse files
Update failure with additional conditions (#18270)
Co-authored-by: Lucas Costi <[email protected]>
1 parent a52a244 commit 994474d

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

content/actions/learn-github-actions/expressions.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -324,34 +324,22 @@ steps:
324324
if: {% raw %}${{ failure() }}{% endraw %}
325325
```
326326

327-
{% ifversion fpt or ghes > 3.3 or ghae-issue-5504 or ghec %}
328-
### Evaluate Status Explicitly
327+
#### failure with conditions
329328

330-
Instead of using one of the methods above, you can evaluate the status of the job or composite action that is executing the step directly:
329+
You can include extra conditions for a step to run after a failure, but you must still include `failure()` to override the default status check of `success()` that is automatically applied to `if` conditions that don't contain a status check function.
331330

332-
#### Example for workflow step
331+
##### Example
333332

334333
```yaml
335334
steps:
336335
...
337-
- name: The job has failed
338-
if: {% raw %}${{ job.status == 'failure' }}{% endraw %}
336+
- name: Failing step
337+
id: demo
338+
run: exit 1
339+
- name: The demo step has failed
340+
if: {% raw %}${{ failure() && steps.demo.conclusion == 'failure' }}{% endraw %}
339341
```
340342

341-
This is the same as using `if: failure()` in a job step.
342-
343-
#### Example for composite action step
344-
345-
```yaml
346-
steps:
347-
...
348-
- name: The composite action has failed
349-
if: {% raw %}${{ github.action_status == 'failure' }}{% endraw %}
350-
```
351-
352-
This is the same as using `if: failure()` in a composite action step.
353-
{% endif %}
354-
355343
## Object filters
356344

357345
You can use the `*` syntax to apply a filter and select matching items in a collection.

0 commit comments

Comments
 (0)