[Actions] Support concurrency syntax #10862

Closed
opened 2025-11-02 09:20:17 -06:00 by GiteaMirror · 13 comments
Owner

Originally created by @lunny on GitHub (May 17, 2023).

Feature Description

simple:

concurrency:
  group: container-release

advanced:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency

Originally created by @lunny on GitHub (May 17, 2023). ### Feature Description simple: ```yaml concurrency: group: container-release ``` advanced: ```yaml concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true ``` https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
Author
Owner

@silverwind commented on GitHub (May 17, 2023):

Edited to also include an advanced example, it's from our current github actions workflows and serves the purpose of cancelling duplicate runs for the same PR.

@silverwind commented on GitHub (May 17, 2023): Edited to also include an advanced example, it's from our current github actions workflows and serves the purpose of cancelling duplicate runs for the same PR.
Author
Owner

@jimafisk commented on GitHub (Nov 6, 2023):

Being able to cancel in-progress builds when a new build comes in would be super helpful for my project! Would love to see this implemented ❤️

Thanks for all your hard work team!

@jimafisk commented on GitHub (Nov 6, 2023): Being able to cancel in-progress builds when a new build comes in would be super helpful for my project! Would love to see this implemented :heart: Thanks for all your hard work team!
Author
Owner

@denyskon commented on GitHub (Nov 6, 2023):

Being able to cancel in-progress builds when a new build comes in would be super helpful for my project! Would love to see this implemented ❤️

Thanks for all your hard work team!

For push events, the auto-cancellation already works on 1.21, you just don't have control over it AFAIK

@denyskon commented on GitHub (Nov 6, 2023): > Being able to cancel in-progress builds when a new build comes in would be super helpful for my project! Would love to see this implemented :heart: > > Thanks for all your hard work team! For push events, the auto-cancellation already works on 1.21, you just don't have control over it AFAIK
Author
Owner

@jimafisk commented on GitHub (Nov 6, 2023):

For push events, the auto-cancellation already works on 1.21, you just don't have control over it AFAIK

Oh that's very interesting, I believe this is the related PR for reference: https://github.com/go-gitea/gitea/pull/25716

Thanks for calling this out @denyskon, you have the best tips!

My understanding is this works off gitea.ref (the branch or tag that triggered the workflow run). I'm adding changes via the API using the /repos/{owner}/{repo}/contents/{filepath} endpoint and it seems to be queuing the actions and completing them one at a time. Do you know if cancellation is possible in this workflow? (I think I'm having trouble because I'm on v1.20.5, I'll upgrade to v1.21 and give it another shot)

Edit: I tested with v1.21.0 that was released yesterday and this works great out of the box. Thank you!

@jimafisk commented on GitHub (Nov 6, 2023): > For push events, the auto-cancellation already works on 1.21, you just don't have control over it AFAIK Oh that's very interesting, I believe this is the related PR for reference: https://github.com/go-gitea/gitea/pull/25716 Thanks for calling this out @denyskon, you have the best tips! My understanding is this works off `gitea.ref` (the branch or tag that triggered the workflow run). ~~I'm adding changes via the API using the `/repos/{owner}/{repo}/contents/{filepath}` endpoint and it seems to be queuing the actions and completing them one at a time. Do you know if cancellation is possible in this workflow?~~ (I think I'm having trouble because I'm on `v1.20.5`, I'll upgrade to `v1.21` and give it another shot) **Edit:** I tested with `v1.21.0` that was released yesterday and this works great out of the box. Thank you!
Author
Owner

@calvinbui commented on GitHub (Dec 8, 2023):

@wolfogre can I request a way to disable the default auto-cancellation (https://github.com/go-gitea/gitea/pull/25716#discussion_r1254228158)

I have a git repo with multiple ansible playbooks and my CI workflow only deploys whichever one was modified in the commit it's running on.

I use renovate to merge a lot of updates and it'll just cancel the deployments midway through. It doesn't even trigger the fail notification step I have as the job is completely gone.

image

@calvinbui commented on GitHub (Dec 8, 2023): @wolfogre can I request a way to disable the default auto-cancellation (https://github.com/go-gitea/gitea/pull/25716#discussion_r1254228158) I have a git repo with multiple ansible playbooks and my CI workflow only deploys whichever one was modified in the commit it's running on. I use renovate to merge a lot of updates and it'll just cancel the deployments midway through. It doesn't even trigger the fail notification step I have as the job is completely gone. ![image](https://github.com/go-gitea/gitea/assets/3604363/1743a8a1-d65b-4df9-a325-065d3774a9f8)
Author
Owner

@wolfogre commented on GitHub (Dec 11, 2023):

@calvinbui Sorry I don't have plans to implement the suggestion I left at https://github.com/go-gitea/gitea/pull/25716#discussion_r1254228158 , maybe others can help.

However, I don't thinks auto-cancellation is a bad idea in your case. What if #522 finisehed first, and then #521 continued deploying (somethink slowed it down) with an older version?

@wolfogre commented on GitHub (Dec 11, 2023): @calvinbui Sorry I don't have plans to implement the suggestion I left at https://github.com/go-gitea/gitea/pull/25716#discussion_r1254228158 , maybe others can help. However, I don't thinks auto-cancellation is a bad idea in your case. What if #522 finisehed first, and then #521 continued deploying (somethink slowed it down) with an older version?
Author
Owner

@calvinbui commented on GitHub (Dec 11, 2023):

@calvinbui Sorry I don't have plans to implement the suggestion I left at #25716 (comment) , maybe others can help.

Can you clarify if you mean Gitea won't implement this or you won't be working on it?

However, I don't thinks auto-cancellation is a bad idea in your case. What if #522 finisehed first, and then #521 continued deploying (somethink slowed it down) with an older version?

In my case, that would be fine. one is updating a tool called notify_push and the other is updating another tool called outline. They are separate files which I am handling. But yes, I understand the conundrem you're explaining.

@calvinbui commented on GitHub (Dec 11, 2023): > @calvinbui Sorry I don't have plans to implement the suggestion I left at [#25716 (comment)](https://github.com/go-gitea/gitea/pull/25716#discussion_r1254228158) , maybe others can help. Can you clarify if you mean Gitea won't implement this or you won't be working on it? > However, I don't thinks auto-cancellation is a bad idea in your case. What if #522 finisehed first, and then #521 continued deploying (somethink slowed it down) with an older version? In my case, that would be fine. one is updating a tool called [notify_push](https://github.com/calvinbui/ansible-monorepo/commit/c88a030b287442fd52173500a9875f13e7d42a91) and the other is updating another tool called [outline](https://github.com/calvinbui/ansible-monorepo/commit/2b36807fd92c11ce47800b8f8c24c5a4a5ca5491). They are separate files which I am [handling](https://github.com/calvinbui/ansible-monorepo/blob/master/scripts/ansible-playbook.sh#L8). But yes, I understand the conundrem you're explaining.
Author
Owner

@wolfogre commented on GitHub (Dec 11, 2023):

Can you clarify if you mean Gitea won't implement this or you won't be working on it?

Sorry for the confusion. I meant to say that I don't have any plans to do it because I'm busy with other things (I thought you were asking me when you mentioned me). I cannot represent Gitea or the Gitea maintainers team. That's why I said "maybe others can help".

@wolfogre commented on GitHub (Dec 11, 2023): > Can you clarify if you mean Gitea won't implement this or you won't be working on it? Sorry for the confusion. I meant to say that I don't have any plans to do it because I'm busy with other things (I thought you were asking me when you mentioned me). I cannot represent Gitea or the Gitea maintainers team. That's why I said "maybe others can help".
Author
Owner

@dh-harald commented on GitHub (Jul 6, 2024):

I'm still struggling with autocancellation.
I've a repository with various dockerfiles, updated by renovatebot.
The pipeline is based on modified directories (i'll add dynamic matrix, if will implemented), so if a Dockerfile changed, it will build a new image. Today morning there was a change in 2 base images, renovate bot created two commits, therefore the first one was instantly cancelled.
I badly need to opt out auto-cancel to avoid this kind of problems

@dh-harald commented on GitHub (Jul 6, 2024): I'm still struggling with autocancellation. I've a repository with various dockerfiles, updated by renovatebot. The pipeline is based on modified directories (i'll add dynamic matrix, if will implemented), so if a Dockerfile changed, it will build a new image. Today morning there was a change in 2 base images, renovate bot created two commits, therefore the first one was instantly cancelled. I badly need to opt out auto-cancel to avoid this kind of problems
Author
Owner

@schlamar commented on GitHub (Nov 28, 2024):

I created a new issue for opt-out from auto-cancelling: #32662

This should be fixed separately from concurrency feature.

@schlamar commented on GitHub (Nov 28, 2024): I created a new issue for opt-out from auto-cancelling: #32662 This should be fixed separately from concurrency feature.
Author
Owner

@lunny commented on GitHub (Jan 14, 2025):

related to #32751

@lunny commented on GitHub (Jan 14, 2025): related to #32751
Author
Owner

@dh-harald commented on GitHub (Feb 14, 2025):

worth mentioning, that ${{ github.head_ref }} returns no value on pull requests merge

@dh-harald commented on GitHub (Feb 14, 2025): worth mentioning, that `${{ github.head_ref }}` returns no value on pull requests merge
Author
Owner

@nis057489 commented on GitHub (Sep 15, 2025):

I just want to chime in to say that I use Gitea to run scientific experiments. It's great to be able to change some variables, push and have CI build, run and create figures from the output of my code. And I have a way to download it all as an artefact, with a commit ID to the exact code that produced the result. What's not so great is pushing and cancelling several of my long running jobs :( It's a bit of a bummer. I'd really love it if there were an option in the settings to not cancel in-progress jobs.

@nis057489 commented on GitHub (Sep 15, 2025): I just want to chime in to say that I use Gitea to run scientific experiments. It's great to be able to change some variables, push and have CI build, run and create figures from the output of my code. And I have a way to download it all as an artefact, with a commit ID to the exact code that produced the result. What's not so great is pushing and cancelling several of my long running jobs :( It's a bit of a bummer. I'd really love it if there were an option in the settings to not cancel in-progress jobs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10862