Interview Prep/CI/CD/GitHub Actions

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' }}
All CI/CD questions

More on GitHub Actions