Skip to content

Commit

Permalink
Prevent concurrent builds on branches (#406)
Browse files Browse the repository at this point in the history
Prevent multiple builds at the same time from the same branch by cancelling the earlier builds. The default branch (e.g. master) is exempted, that is, builds from the default branch may run concurrently.
  • Loading branch information
erikvanoosten authored Jun 25, 2024
1 parent b87dcc2 commit 8116d65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ env:
pull_request:
branches-ignore:
- gh-pages
concurrency:
group: ${{ github.workflow }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.run_id || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ object Workflow {
.map(_.toKeyValuePair): _*
)
}),
"concurrency" := Json.obj(
"group" := Json.fromString(
"${{ github.workflow }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.run_id || github.ref }}"
),
"cancel-in-progress" := true
),
"jobs" := Json.obj(wf.jobs.map(job => job.id := job): _*)
)
}

0 comments on commit 8116d65

Please sign in to comment.