Skip to content

Commit a78cac6

Browse files
authored
chore: enforce concurrency with GitHub feature (coder#844)
Use GitHub's concurrency feature to cancel in-progress builds on pull request events, and serialize builds for branch push events.
1 parent d08bd45 commit a78cac6

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ permissions:
2424
security-events: none
2525
statuses: none
2626

27+
# Cancel in-progress runs for pull requests when developers push
28+
# additional changes, and serialize builds in branches.
29+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.ref }}
32+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
33+
2734
jobs:
2835
lint:
2936
name: Lint
3037
runs-on: ubuntu-20.04
3138
steps:
32-
- name: Cancel Previous Runs
33-
if: github.ref != 'refs/heads/master'
34-
uses: styfle/cancel-workflow-action@0.9.1
35-
3639
- name: Checkout
3740
uses: actions/checkout@v2
3841
with:

.github/workflows/preview.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ permissions:
1818
security-events: none
1919
statuses: none
2020

21+
# Cancel in-progress runs for pull requests when developers push
22+
# additional changes, and serialize builds in branches.
23+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
27+
2128
jobs:
2229
preview:
2330
name: Preview
2431
runs-on: ubuntu-20.04
2532
steps:
26-
- name: Cancel Previous Runs
27-
uses: styfle/cancel-workflow-action@0.9.1
28-
2933
- name: Checkout m
3034
uses: actions/checkout@v2
3135
with:

.github/workflows/production.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ permissions:
1919
security-events: none
2020
statuses: none
2121

22+
# Cancel in-progress runs for pull requests when developers push
23+
# additional changes, and serialize builds in branches.
24+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
28+
2229
jobs:
2330
production:
2431
name: Production
2532
runs-on: ubuntu-20.04
2633
steps:
27-
- name: Cancel Previous Runs
28-
uses: styfle/cancel-workflow-action@0.9.1
29-
3034
- name: Checkout m
3135
uses: actions/checkout@v2
3236
with:

0 commit comments

Comments
 (0)