Skip to content

Commit 36b794c

Browse files
bartsdevBartclaude
authored
ci: approve Dependabot PRs and enable auto-merge, as lstk does (#162)
The workflow no longer polls checks and merges itself. Like lstk's, the bot approves the PR and turns on GitHub's auto-merge, which squash-merges once the main ruleset's required checks pass. Major updates still wait for a maintainer. The bot token reaches only the two gh steps. Needs the repository's auto-merge setting, and build, mcp-direct-tests and mcp-tool-tests as required checks in the main ruleset. Co-authored-by: Bart <bart@Barts-MacBook-Pro.local> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5af997d commit 36b794c

1 file changed

Lines changed: 22 additions & 56 deletions

File tree

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
name: Dependabot auto-merge
1+
name: Dependabot Auto-merge
22

3-
# Merges Dependabot's minor and patch PRs once their checks pass. Major updates wait for a maintainer.
4-
# The gate lives here rather than in the main ruleset's required checks, so it applies to Dependabot
5-
# PRs only: the job waits for every other check on the PR's head commit to finish, requires the CI
6-
# jobs below to pass and none to fail, then squash-merges that exact commit. It needs no repository
7-
# auto-merge setting.
3+
# Same shape as lstk's: the bot approves Dependabot's PR and turns on GitHub's auto-merge, which
4+
# squash-merges it once the main ruleset's required checks pass. Major updates wait for a maintainer.
85
#
9-
# pull_request_target gives this job secrets on Dependabot PRs. It never checks out or runs the PR's
10-
# code, only reads its metadata and calls the GitHub API (REVIEW §0).
6+
# pull_request_target runs main's copy of this file with the repository's secrets. It never checks
7+
# out or runs the PR's code, only reads its metadata and calls the GitHub API (REVIEW §0).
118
on: # zizmor: ignore[dangerous-triggers] no checkout, no PR code runs
129
pull_request_target:
13-
types: [opened, synchronize, reopened, ready_for_review]
10+
types: [opened, reopened, synchronize]
1411

12+
# gh runs with the localstack-bot token: a merge made with GITHUB_TOKEN would start no workflows on
13+
# main. GITHUB_TOKEN only lets fetch-metadata read the PR.
1514
permissions:
16-
contents: read
1715
pull-requests: read
1816

19-
# A new push to the PR cancels the wait for the old commit.
20-
concurrency:
21-
group: dependabot-auto-merge-${{ github.event.pull_request.number }}
22-
cancel-in-progress: true
23-
2417
jobs:
2518
auto-merge:
26-
name: Merge when checks pass
27-
# Both: the PR is Dependabot's, and Dependabot made this push, not someone pushing to its branch.
28-
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.actor == 'dependabot[bot]'
19+
name: Approve and enable auto-merge
20+
# The PR is Dependabot's, Dependabot made this push (not someone pushing to its branch), and this
21+
# is not a fork.
22+
if: >-
23+
github.event.pull_request.user.login == 'dependabot[bot]' &&
24+
github.actor == 'dependabot[bot]' &&
25+
github.repository == 'localstack/localstack-mcp-server'
2926
runs-on: ubuntu-26.04
30-
# CI and the image smoke tests take about 10 minutes; leave room for queueing.
31-
timeout-minutes: 90
27+
timeout-minutes: 5
3228
steps:
3329
# Verifies the commits are Dependabot's own and reports the largest update in the PR (a group
3430
# reports its largest member).
@@ -42,47 +38,17 @@ jobs:
4238
DEPS: ${{ steps.meta.outputs.dependency-names }}
4339
run: echo "::notice::Major update ($DEPS); not auto-merging."
4440

45-
- name: Wait for the checks
41+
- name: Approve
4642
if: steps.meta.outputs.update-type != 'version-update:semver-major'
4743
env:
48-
GH_TOKEN: ${{ github.token }}
44+
GH_TOKEN: ${{ secrets.LOCALSTACK_BOT_TOKEN }}
4945
PR_URL: ${{ github.event.pull_request.html_url }}
50-
SELF: ${{ github.workflow }}
51-
REQUIRED: "build mcp-direct-tests mcp-tool-tests"
52-
run: |
53-
set -euo pipefail
54-
# Give the PR's other workflows time to register their checks.
55-
sleep 60
56-
while :; do
57-
# gh exits non-zero while checks are pending or failing; the JSON is still printed.
58-
checks=$(gh pr checks "$PR_URL" --json name,bucket,workflow || true)
59-
others=$(jq --arg self "$SELF" '[.[] | select(.workflow != $self)]' <<<"${checks:-[]}")
60-
failed=$(jq -r '.[] | select(.bucket == "fail" or .bucket == "cancel") | .name' <<<"$others")
61-
if [ -n "$failed" ]; then
62-
echo "::error::Checks failed, not merging: $(tr '\n' ' ' <<<"$failed")"
63-
exit 1
64-
fi
65-
missing=""
66-
for name in $REQUIRED; do
67-
jq -e --arg n "$name" 'any(.[]; .name == $n and .bucket == "pass")' <<<"$others" >/dev/null \
68-
|| missing="$missing $name"
69-
done
70-
pending=$(jq '[.[] | select(.bucket == "pending")] | length' <<<"$others")
71-
if [ -z "$missing" ] && [ "$pending" = 0 ]; then
72-
echo "All checks passed."
73-
break
74-
fi
75-
echo "Waiting: $pending pending; required not passed yet:${missing:- none}"
76-
sleep 30
77-
done
46+
run: gh pr review "$PR_URL" --approve
7847

79-
# The bot token, not GITHUB_TOKEN: a merge made with GITHUB_TOKEN starts no workflows, so the
80-
# push to main would skip CI, the image push and the evals. --match-head-commit refuses to merge
81-
# if the PR moved past the commit whose checks passed.
82-
- name: Merge
48+
# Merges once the main ruleset's required checks pass.
49+
- name: Enable auto-merge
8350
if: steps.meta.outputs.update-type != 'version-update:semver-major'
8451
env:
8552
GH_TOKEN: ${{ secrets.LOCALSTACK_BOT_TOKEN }}
8653
PR_URL: ${{ github.event.pull_request.html_url }}
87-
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
88-
run: gh pr merge "$PR_URL" --squash --match-head-commit "$HEAD_SHA"
54+
run: gh pr merge "$PR_URL" --auto --squash

0 commit comments

Comments
 (0)