From ffe125451c382570cffdadc2ef7a395d7e395312 Mon Sep 17 00:00:00 2001 From: Erik Brinkman Date: Thu, 1 Oct 2026 19:06:44 -0400 Subject: [PATCH] ci: mention me when automerge leaves a pull request open --- .github/workflows/automerge.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 4dd11fc..f8c95f0 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -9,7 +9,7 @@ on: jobs: merge: - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.actor.login == 'dependabot[bot]' + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.actor.login == 'dependabot[bot]' runs-on: ubuntu-latest permissions: contents: write @@ -18,8 +18,17 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # nothing is checked out here, so gh has no remote to infer the repo from GH_REPO: ${{ github.repository }} + BRANCH: ${{ github.event.workflow_run.head_branch }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} steps: - - run: gh pr merge --squash --match-head-commit "$HEAD_SHA" "$BRANCH" + - if: github.event.workflow_run.conclusion == 'success' + run: gh pr merge --squash --match-head-commit "$HEAD_SHA" "$BRANCH" + # a cancelled build or a pull request that has since moved on gets another run, so + # neither is worth a mention + - if: failure() || github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out' + run: | + if [ "$(gh pr view "$BRANCH" --json state,headRefOid --jq '"\(.state) \(.headRefOid)"')" = "OPEN $HEAD_SHA" ]; then + gh pr comment "$BRANCH" --body "@erikbrinkman automerge left this open: $REASON" + fi env: - BRANCH: ${{ github.event.workflow_run.head_branch }} - HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + REASON: ${{ github.event.workflow_run.conclusion == 'success' && 'the merge failed' || 'the build failed' }}