Skip to content

Commit ba25815

Browse files
committed
fix(ci): use head_ref in MegaLinter concurrency group to prevent self-cancellation
When a PR is merged, GitHub fires both a push event and a pull_request[closed] event simultaneously. Since the 2023 fix to github.ref, both events resolve to refs/heads/main, placing them in the same concurrency group. With cancel-in-progress: true, the closed event cancels the push run, then immediately skips (due to the if: github.event.action != 'closed' guard), leaving no surviving MegaLinter run. Fix: use github.head_ref (the PR source branch) with a fallback to github.ref (for push events). This keeps closed events in the PR's concurrency group so they cancel in-progress PR runs as intended, without interfering with push-triggered runs on main.
1 parent db158f8 commit ba25815

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

.github/workflows/megalinter.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ on:
44
push:
55
branches: [main]
66
pull_request:
7-
types:
8-
- opened
9-
- synchronize
10-
- reopened
11-
- closed
7+
types: [opened, synchronize, reopened, closed]
128

139
permissions:
1410
contents: read
1511
security-events: write
1612

1713
concurrency:
18-
group: ${{ github.workflow }}-${{ github.ref }}
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1915
cancel-in-progress: true
2016

2117
jobs:

0 commit comments

Comments
 (0)