From c0da20e6c2f5eaa45f9691ef398f8285fe9d14b6 Mon Sep 17 00:00:00 2001 From: Alex Brazier Date: Thu, 26 May 2022 21:00:47 +0100 Subject: [PATCH 1/3] Update failure with additional conditions --- .../learn-github-actions/expressions.md | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/content/actions/learn-github-actions/expressions.md b/content/actions/learn-github-actions/expressions.md index 14fe4cc00b1e..fcf88914f17c 100644 --- a/content/actions/learn-github-actions/expressions.md +++ b/content/actions/learn-github-actions/expressions.md @@ -324,34 +324,21 @@ steps: if: {% raw %}${{ failure() }}{% endraw %} ``` -{% ifversion fpt or ghes > 3.3 or ghae-issue-5504 or ghec %} -### Evaluate Status Explicitly - -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: - -#### Example for workflow step - -```yaml -steps: - ... - - name: The job has failed - if: {% raw %}${{ job.status == 'failure' }}{% endraw %} -``` +### failure with conditions -This is the same as using `if: failure()` in a job step. - -#### Example for composite action step +If you want to check more conditions on the failure step you can use `failure()` with additional conditions. Note `failure()` is always required or the step will be skipped on fail. +### Example ```yaml steps: ... - - name: The composite action has failed - if: {% raw %}${{ github.action_status == 'failure' }}{% endraw %} + - name: Failing job + id: demo + run: exit 1 + - name: The demo job has failed + if: {% raw %}${{ failure() && steps.demo.conclusion == '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. From c71678d35ca454797005eb703a6ff4ee0bb514ea Mon Sep 17 00:00:00 2001 From: Alex Brazier Date: Thu, 26 May 2022 21:42:13 +0100 Subject: [PATCH 2/3] Update formatting and copy --- content/actions/learn-github-actions/expressions.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/actions/learn-github-actions/expressions.md b/content/actions/learn-github-actions/expressions.md index fcf88914f17c..9185fd05057d 100644 --- a/content/actions/learn-github-actions/expressions.md +++ b/content/actions/learn-github-actions/expressions.md @@ -326,16 +326,17 @@ steps: ### failure with conditions -If you want to check more conditions on the failure step you can use `failure()` with additional conditions. Note `failure()` is always required or the step will be skipped on fail. +For a step to run after a failure you can include extra conditions but you must include `failure()` for it to be detected as a step that should run. + +#### Example -### Example ```yaml steps: ... - - name: Failing job + - name: Failing step id: demo run: exit 1 - - name: The demo job has failed + - name: The demo step has failed if: {% raw %}${{ failure() && steps.demo.conclusion == 'failure' }}{% endraw %} ``` From ef6e4b2348c440dcb2d016879fced6eeaf3992bc Mon Sep 17 00:00:00 2001 From: Lucas Costi Date: Wed, 1 Jun 2022 14:37:18 +1000 Subject: [PATCH 3/3] Update expressions.md --- content/actions/learn-github-actions/expressions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/actions/learn-github-actions/expressions.md b/content/actions/learn-github-actions/expressions.md index 9185fd05057d..e161ce8f6c86 100644 --- a/content/actions/learn-github-actions/expressions.md +++ b/content/actions/learn-github-actions/expressions.md @@ -324,11 +324,11 @@ steps: if: {% raw %}${{ failure() }}{% endraw %} ``` -### failure with conditions +#### failure with conditions -For a step to run after a failure you can include extra conditions but you must include `failure()` for it to be detected as a step that should run. +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 +##### Example ```yaml steps: