Is it possible to use an expression in concurrency cancel-in-progress #69704
Replies: 6 comments 6 replies
-
This StackOverflow answer seems to suggest that an expression in |
Beta Was this translation helpful? Give feedback.
-
Expressions work, this is from the docs:
Note that a lot of parameters are not available at the time when the concurrency key is evaluated ( Input parameters are available (strategy matrix parameters too for jobs), this is what I'm using for example: |
Beta Was this translation helpful? Give feedback.
-
Yes, expressions are supported for the The available contexts for cancel-in-progress expressions are: github: This context provides access to various GitHub-specific variables, such as inputs: This context allows you to access input parameters defined in the workflow. This is particularly useful for conditional cancellation based on user-specified settings. vars: This context provides access to workflow-defined variables, which can be used to store intermediate values or constants. When evaluating expressions for Example of Using an Expression for Consider a workflow that needs to cancel in-progress runs only for pull requests but allow them to complete on the main branch. Here's how you can achieve this using an expression: |
Beta Was this translation helpful? Give feedback.
-
Is there some actual official GitHub documentation on this topic. I'm seeing the same behaviour that my workflow with the following: concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: ${{ !contains(github.ref_name, 'release/') }} Is still cancelling concurrent builds on Did I just make an error in my conditional here? Or is there something else going on? |
Beta Was this translation helpful? Give feedback.
-
I want the previous workflows to cancel if they have not yet begun, and I had the idea of using the expression |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
I have a workflow where for pull requests I want the workflow to cancel any in-progress run if a new commit is pushed to the PR branch but for the
main
branch have the workflows run to completion (but still limit to 1 active workflow)In the documentation I see
cancel-in-progress
is always set totrue
, however I'd like to use an expression but can't confirm if that is supported.So given this (abbreviated) workflow:
GitHub accepts the workflow (no invalid workflow errors) but it keeps cancelling the workflows on
main
when a new commit is pushed.Are expression supported for
cancel-in-progress
?Beta Was this translation helpful? Give feedback.
All reactions