diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..4d33552 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,41 @@ +name: Dependabot auto-merge + +on: + pull_request_target: + branches: [master] + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + name: Auto-merge low-risk Dependabot PRs + if: github.event.pull_request.user.login == 'dependabot[bot]' + runs-on: ubuntu-latest + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + # Arming auto-merge is the whole job, and the merge still waits for CI: + # `--auto` queues it behind the required checks rather than merging now. + # There is no approve step on purpose. GITHUB_TOKEN cannot approve a pull + # request ("Allow GitHub Actions to create and approve pull requests" is + # off org-wide), so an approve step would fail on every single bump, and a + # check that is always red teaches you to stop reading red checks. + # + # Scope is deliberately narrow: workflow action bumps only, minor and + # patch. A pub dependency reaches the package's own resolution graph and a + # major bump is a breaking change by declaration, so both keep a human. + - name: Arm auto-merge for GH Actions minor + patch + if: | + steps.metadata.outputs.package-ecosystem == 'github_actions' && + (steps.metadata.outputs.update-type == 'version-update:semver-minor' || + steps.metadata.outputs.update-type == 'version-update:semver-patch') + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh pr merge --auto --squash "$PR_URL"