Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/dependabot-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ jobs:
echo "$PACKAGE $VERSION is $age days old."
echo "old_enough=true" >> "$GITHUB_OUTPUT"

- name: Verify latest CI run and squash merge
- name: Verify latest CI run, approve and squash merge
if: >
steps.pr.outputs.number != '' &&
steps.update_type.outputs.skip == 'false' &&
Expand All @@ -212,5 +212,21 @@ jobs:
echo "CI was superseded, rerun or is not successful; not auto-merging."
exit 0
fi
gh pr merge "$PR" --repo "$REPO" --squash --delete-branch \
--match-head-commit "$HEAD_SHA"
# The org's "Review required" ruleset wants one approval, and
# without it the merge below is refused. The approval is pinned to
# the commit CI just passed. The ruleset does not dismiss stale
# approvals on push, so a failed merge dismisses it: left in place,
# it would let a later push merge without a human review.
# Needs "Allow GitHub Actions to create and approve pull requests"
# in the repo's Actions settings.
review_id=$(gh api "/repos/$REPO/pulls/$PR/reviews" \
-f commit_id="$HEAD_SHA" -f event=APPROVE \
-f body='Stable patch or minor update, CI passed, release old enough.' \
--jq .id)
if ! gh pr merge "$PR" --repo "$REPO" --squash --delete-branch \
--match-head-commit "$HEAD_SHA"; then
gh api -X PUT "/repos/$REPO/pulls/$PR/reviews/$review_id/dismissals" \
-f message='Auto-merge failed; approval withdrawn.' > /dev/null || \
echo "::error::Merge failed and the approval could not be dismissed. Dismiss review $review_id on #$PR by hand."
exit 1
fi
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ Major, 0.x, prerelease, grouped and unrecognized titles remain manual. The workf
requires a unique open, nondraft Dependabot PR from the same repository to `main`,
the exact current head, and a successful latest run and attempt of the triggering
CI workflow. Actions-only changes require the complete paginated file list,
including previous paths for renames. Merge uses `--match-head-commit` without
an administrative bypass.
including previous paths for renames. The workflow then approves the PR at the
head CI passed, which the org's "Review required" ruleset needs, and merges with
`--match-head-commit` without an administrative bypass. If the merge fails, the
workflow dismisses its approval, because the ruleset keeps approvals after a
push. The approval needs
"Allow GitHub Actions to create and approve pull requests" on in the caller
repository's Actions settings; without it, the workflow fails at the approval.

Two more guards apply to every caller:

Expand Down
Loading