Skip to content

Commit 021eeae

Browse files
Dependabot flow fine tuning (#5331)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 29b46b5 commit 021eeae

2 files changed

Lines changed: 6 additions & 30 deletions

File tree

.github/workflows/dependabot-changeset.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212

1313
permissions:
1414
contents: write # push the changeset commit
15-
actions: write # dispatch repo.yaml on the new head
1615

1716
concurrency:
1817
group: '${{ github.workflow }}-${{ github.head_ref }}'
@@ -23,10 +22,13 @@ jobs:
2322
name: Generate changeset
2423
runs-on: ubuntu-latest
2524
# Only same-repo PRs authored by dependabot. PR author (not actor) so a
26-
# human reopening/rebasing the PR still gets a changeset regenerated.
25+
# human reopening/rebasing the PR still gets a changeset regenerated, but
26+
# never react to our own changeset commit (sender is the pusher on
27+
# `synchronize`, and the commit below is made as github-actions[bot]).
2728
if: >
2829
github.event.pull_request.user.login == 'dependabot[bot]' &&
29-
github.event.pull_request.head.repo.full_name == github.repository
30+
github.event.pull_request.head.repo.full_name == github.repository &&
31+
github.event.sender.login != 'github-actions[bot]'
3032
steps:
3133
- uses: actions/checkout@v4
3234
with:
@@ -84,14 +86,3 @@ jobs:
8486
git commit -m 'Sync changeset with Dependabot update'
8587
git push origin "HEAD:$HEAD_REF"
8688
echo 'pushed=true' >>"$GITHUB_OUTPUT"
87-
88-
# A push made with GITHUB_TOKEN does not re-trigger pull_request
89-
# workflows, so the new head commit would show no checks. Explicit
90-
# workflow_dispatch is exempt from that rule and attaches its check
91-
# runs to the new head commit.
92-
- name: Re-run CI on the new head
93-
if: steps.generate.outputs.pushed == 'true'
94-
env:
95-
GH_TOKEN: ${{ github.token }}
96-
HEAD_REF: ${{ github.event.pull_request.head.ref }}
97-
run: gh workflow run repo.yaml --repo "$GITHUB_REPOSITORY" --ref "$HEAD_REF"

.github/workflows/repo.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,12 @@ name: Repository CI
22

33
on:
44
pull_request:
5-
# Dispatched by dependabot-changeset.yml after it pushes a changeset commit:
6-
# pushes made with GITHUB_TOKEN don't trigger pull_request runs, so checks
7-
# for the new head commit have to be created explicitly. Required status
8-
# checks match on check-run (job) names, so those dispatched runs only
9-
# satisfy the merge gate as long as job names don't depend on the event
10-
# type.
11-
workflow_dispatch:
125

13-
# Read-only: every job here only checks out and builds. Declared explicitly
14-
# because workflow_dispatch runs would otherwise inherit the repository-default
15-
# token scopes, which can include write.
166
permissions:
177
contents: read
188

199
concurrency:
20-
# head_ref is only set on pull_request runs; ref_name covers the
21-
# workflow_dispatch re-runs. Both resolve to the bare branch name (unlike
22-
# ref, which is the fully qualified refs/heads/... on dispatch), so a
23-
# dispatched re-run cancels the same branch's in-flight PR run and
24-
# vice-versa instead of running alongside it.
25-
group: '${{ github.workflow }}-${{ github.head_ref || github.ref_name }}'
10+
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
2611
cancel-in-progress: true
2712

2813
jobs:

0 commit comments

Comments
 (0)