From 1f64780ea9e54ce6411dbf33b43002069cf680b9 Mon Sep 17 00:00:00 2001 From: Imani Manyara Date: Tue, 13 Oct 2026 09:05:49 -0400 Subject: [PATCH] Skip Dependabot auto-merge while the repository disallows it gh pr merge --auto fails with "Auto merge is not allowed for this repository" while the repository setting is off, so the dependabot job went red on every Dependabot pull request. Read allow_auto_merge first, and when it is off, leave a notice and the pull request for a manual merge. The check step is copied verbatim from laranail/license-kit#19, and the single merge step in this variant of the workflow is gated on it, so the guard stays identical. The repository setting itself is unchanged. --- .github/workflows/dependabot-auto-merge.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 9fcb9c3..6a3f302 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -34,8 +34,25 @@ jobs: id: meta uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 + # The merge steps below call `gh pr merge --auto`, which GitHub refuses outright ("Auto merge + # is not allowed for this repository") while the repository setting is off. That failed this + # job on every Dependabot pull request and showed a red check on each one. Read the setting + # first: when it is off, say so and leave the pull request for a person to merge. + - name: Check that the repository allows auto-merge + id: repo + run: | + allowed=$(gh api "repos/$REPO" --jq .allow_auto_merge) + echo "allowed=$allowed" >> "$GITHUB_OUTPUT" + if [ "$allowed" != "true" ]; then + echo "::notice title=Auto-merge is off for this repository::Leaving $PR_URL for a manual merge. Enable 'Allow auto-merge' in the repository settings to have minor and patch updates merge themselves." + fi + env: + REPO: ${{ github.repository }} + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Enable auto-merge for patch & minor updates - if: ${{ steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor' }} + if: ${{ steps.repo.outputs.allowed == 'true' && (steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor') }} run: gh pr merge --auto --merge --delete-branch "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }}