Skip to content

Commit deeb1fa

Browse files
committed
ci(github): trigger automerge on workflow_run instead of pull_request
The workflow previously triggered on every pull_request and skipped immediately for non-Dependabot PRs, wasting a runner allocation. Switch to workflow_run on CI completion. The job-level condition gates on both CI success and the Dependabot actor, so non-Dependabot PRs never provision a runner at all. As a side effect, auto-merge is now only attempted after CI passes rather than racing against it.
1 parent acb3984 commit deeb1fa

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

.github/workflows/automerge.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Auto-merge Dependabot
22

33
on:
4-
pull_request:
5-
branches: [master]
4+
workflow_run:
5+
workflows: [CI]
6+
types: [completed]
67

78
permissions:
89
contents: write
@@ -14,17 +15,21 @@ env:
1415
jobs:
1516
automerge:
1617
runs-on: ubuntu-latest
17-
if: github.actor == 'dependabot[bot]'
18+
if: |
19+
github.event.workflow_run.conclusion == 'success' &&
20+
github.event.workflow_run.actor.login == 'dependabot[bot]'
1821
steps:
1922
- name: Fetch Dependabot metadata
2023
id: metadata
2124
uses: dependabot/fetch-metadata@v2
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
2227

2328
- name: Enable auto-merge for patch and minor updates
2429
if: |
2530
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
2631
steps.metadata.outputs.update-type == 'version-update:semver-minor'
2732
run: gh pr merge --auto --squash "$PR_URL"
2833
env:
29-
PR_URL: ${{ github.event.pull_request.html_url }}
34+
PR_URL: ${{ github.event.workflow_run.pull_requests[0].url }}
3035
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)