You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/actions/creating-actions/metadata-syntax-for-github-actions.md
+32-2Lines changed: 32 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,8 @@ runs:
175
175
176
176
### `pre-if`
177
177
178
-
**Optional** Allows you to define conditions for the `pre:` action execution. The `pre:` action will only run if the conditions in `pre-if` are met. If not set, then `pre-if` defaults to `always()`.
178
+
**Optional** Allows you to define conditions for the `pre:` action execution. The `pre:` action will only run if the conditions in `pre-if` are met. If not set, then `pre-if` defaults to `always()`. In `pre-if`, status check functions evaluate against the job's status, not the action's own status.
179
+
179
180
Note that the `step` context is unavailable, as no steps have run yet.
180
181
181
182
In this example, `cleanup.js` only runs on Linux-based runners:
@@ -202,7 +203,7 @@ The `post:` action always runs by default but you can override this using `post-
202
203
203
204
### `post-if`
204
205
205
-
**Optional** Allows you to define conditions for the `post:` action execution. The `post:` action will only run if the conditions in `post-if` are met. If not set, then `post-if` defaults to `always()`.
206
+
**Optional** Allows you to define conditions for the `post:` action execution. The `post:` action will only run if the conditions in `post-if` are met. If not set, then `post-if` defaults to `always()`. In `post-if`, status check functions evaluate against the job's status, not the action's own status.
206
207
207
208
For example, this `cleanup.js` will only run on Linux-based runners:
208
209
@@ -265,6 +266,35 @@ For more information, see "[`github context`](/actions/reference/context-and-exp
265
266
**Required** The shell where you want to run the command. You can use any of the shells listed [here](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsshell). Required if `run` is set.
266
267
{% endif %}
267
268
269
+
#### `runs.steps[*].if`
270
+
271
+
**Optional** You can use the `if` conditional to prevent a step from running unless a condition is met. You can use any supported context and expression to create a conditional.
272
+
273
+
{% data reusables.github-actions.expression-syntax-if %} For more information, see "[Expressions](/actions/learn-github-actions/expressions)."
274
+
275
+
**Example: Using contexts**
276
+
277
+
This step only runs when the event type is a `pull_request` and the event action is `unassigned`.
278
+
279
+
```yaml
280
+
steps:
281
+
- run: echo This event is a pull request that had an assignee removed.
The `my backup step` only runs when the previous step of a composite action fails. For more information, see "[Expressions](/actions/learn-github-actions/expressions#job-status-check-functions)."
0 commit comments