diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..74da403 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: Dependabot auto-merge + +# Turns on GitHub's native auto-merge for Dependabot pull requests, so a PR whose +# every required status check passes merges itself instead of waiting for a human. +# Branch protection still fully gates the merge — nothing red lands, and required +# checks/reviews are still enforced. +# +# Scope: minor and patch updates only. Major bumps are left open for a human to read +# the changelog first. Uses only the automatic GITHUB_TOKEN — no PAT or extra secrets. +# Requires "Allow auto-merge" in Settings > General (enabled for this repo). + +on: pull_request + +permissions: + contents: write # enable auto-merge on the PR + pull-requests: write # required by gh pr merge + +jobs: + auto-merge: + if: github.actor == 'dependabot[bot]' + runs-on: ubuntu-latest + steps: + - name: Fetch Dependabot metadata + id: meta + uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 + + - name: Enable auto-merge for non-major updates + if: steps.meta.outputs.update-type != 'version-update:semver-major' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}