Single Workflow Concurrency

I’ve just come across this new amazing feature Workflow syntax for GitHub Actions - GitHub Docs which is still in beta and I’m wondering if it’s possible to implement a method of controlling concurrency of one workflow. For example: the workflow is ran 5 times, we want to cancel all previous runs but keep the newest one; How would one achieve this?

1 Like

At the top level of your workflow, add

concurrency:
  group: workflow-xyz
  cancel-in-progress: true

You can use any string as group name, just make sure you don’t use it in any other workflow again. You may use ${{ github.workflow }} which is the workflow name or file path.

1 Like