Skip to content

Commit 1894c03

Browse files
rvesseSiaraMist
andauthored
Clarify concurrency cancel-in-progress behaviour (#30647)
Co-authored-by: Siara <[email protected]>
1 parent 14c9d73 commit 1894c03

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

data/reusables/actions/actions-group-concurrency.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
When a concurrent job or workflow is queued, if another job or workflow run using the same concurrency group in the repository is in progress, the queued job or workflow run will be `pending`. Any pending job or workflow run in the same concurrency group will be canceled when a new job or workflow run is queued. To also cancel any currently running job or workflow run in the same concurrency group, specify `cancel-in-progress: true`.
1+
When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress, the queued job or workflow will be `pending`. Any pending job or workflow in the concurrency group will be canceled. This means that there can be at most one running and one pending job in a concurrency group at any time.
2+
3+
To also cancel any currently running job or workflow in the same concurrency group, specify `cancel-in-progress: true`. To conditionally cancel currently running jobs or workflows in the same concurrency group, you can specify `cancel-in-progress` as an expression with any of the allowed expression contexts.
24

35
{% note %}
46

@@ -129,3 +131,21 @@ concurrency:
129131
```
130132

131133
{% endraw %}
134+
135+
### Example: Only cancel in-progress jobs on specific branches
136+
137+
If you would like to cancel in-progress jobs on certain branches but not on others, you can use conditional expressions with `cancel-in-progress`. For example, you can do this if you would like to cancel in-progress jobs on development branches but not on release branches.
138+
139+
To only cancel in-progress runs of the same workflow when not running on a release branch, you can set `cancel-in-progress` to an expression similar to the following:
140+
141+
{% raw %}
142+
143+
```yaml
144+
concurrency:
145+
group: ${{ github.workflow }}-${{ github.ref }}
146+
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
147+
```
148+
149+
{% endraw %}
150+
151+
In this example, multiple pushes to a `release/1.2.3` branch would not cancel in-progress runs. Pushes to another branch, such as `main`, would cancel in-progress runs.

0 commit comments

Comments
 (0)