How does `concurrency` work and when do you use `cancel-in-progress`?
IntermediateConceptGitHub Actions
Answer
concurrency.group ensures only one run (or job) with that group key runs at a time; others queue (only one pending is kept) or cancel the running one if cancel-in-progress: true. For PR CI we cancel superseded runs to save minutes. For deployments we usually do not cancel in progress, to avoid a half-finished deploy, and just serialise.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate