diff --git a/content/actions/learn-github-actions/expressions.md b/content/actions/learn-github-actions/expressions.md index 14fe4cc00b1e..e161ce8f6c86 100644 --- a/content/actions/learn-github-actions/expressions.md +++ b/content/actions/learn-github-actions/expressions.md @@ -324,34 +324,22 @@ steps: if: {% raw %}${{ failure() }}{% endraw %} ``` -{% ifversion fpt or ghes > 3.3 or ghae-issue-5504 or ghec %} -### Evaluate Status Explicitly +#### failure with conditions -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: +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. -#### Example for workflow step +##### Example ```yaml steps: ... - - name: The job has failed - if: {% raw %}${{ job.status == 'failure' }}{% endraw %} + - name: Failing step + id: demo + run: exit 1 + - name: The demo step has failed + if: {% raw %}${{ failure() && steps.demo.conclusion == 'failure' }}{% endraw %} ``` -This is the same as using `if: failure()` in a job step. - -#### Example for composite action step - -```yaml -steps: - ... - - name: The composite action has failed - if: {% raw %}${{ github.action_status == 'failure' }}{% endraw %} -``` - -This is the same as using `if: failure()` in a composite action step. -{% endif %} - ## Object filters You can use the `*` syntax to apply a filter and select matching items in a collection.