-
Hi community, When I tried to use the new feature concurrency in Github Actions, I find I don’t know how to choose the appropriate field for Is there any other recommendation on what to fill in |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
It depends exactly what level of concurrency you want. You could use Can you give some more specifics on exactly what you’re aiming for when setting this up? That way we might be able to suggest a better option for you to use. |
Beta Was this translation helpful? Give feedback.
-
Hi Thomas thanks for your prompt reply and glad to know the supported function of concurrency! Actually what I want is to limit it to branch level. For example, if one action would be triggered by both push and pull_request, I want only two workflows running for this branch/PR, one for push and one for pr, and the latest commit would cancel the workflows triggered by previous ones. How should I implement this? |
Beta Was this translation helpful? Give feedback.
-
The last setup you tried looks like it should work and do what you want.
I would expect a second push to the same branch to cancel an in-flight workflow run triggered by a push. Do I understand correctly, that both workflows are executed in parallel and both succeed instead of one being canceled and the other succeeding? |
Beta Was this translation helpful? Give feedback.
-
Thank you Simran it solved the problem! It seems I forgot to make another push to test it 🤣 |
Beta Was this translation helpful? Give feedback.
-
I’d like to do the same thing as @Yiyiyimu but I want the concurrency setting to apply to every branch EXCEPT the master branch. Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
-
I guess something like this should work:
If it’s a push to the master branch, then it uses the run number which is unique (except if you re-run a workflow), so it shouldn’t cancel other concurrent runs. If it’s not the master branch, then only a single run per branch is allowed. You could probably use github.run_id or github.sha instead of github.run_number with the same result. |
Beta Was this translation helpful? Give feedback.
-
i hope your problem was solved |
Beta Was this translation helpful? Give feedback.
The last setup you tried looks like it should work and do what you want.
I would expect a second push to the same branch to cancel an in-flight workflow run triggered by a push.
Do I understand correctly, that both workflows are executed in parallel and both succeed instead of one being canceled and the other succeeding?