diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 1bf39d1..7cb0d5c 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -1,34 +1,30 @@ -name: Dependabot auto-merge +name: Dependabot Auto-merge -# Merges Dependabot's minor and patch PRs once their checks pass. Major updates wait for a maintainer. -# The gate lives here rather than in the main ruleset's required checks, so it applies to Dependabot -# PRs only: the job waits for every other check on the PR's head commit to finish, requires the CI -# jobs below to pass and none to fail, then squash-merges that exact commit. It needs no repository -# auto-merge setting. +# Same shape as lstk's: the bot approves Dependabot's PR and turns on GitHub's auto-merge, which +# squash-merges it once the main ruleset's required checks pass. Major updates wait for a maintainer. # -# pull_request_target gives this job secrets on Dependabot PRs. It never checks out or runs the PR's -# code, only reads its metadata and calls the GitHub API (REVIEW §0). +# pull_request_target runs main's copy of this file with the repository's secrets. It never checks +# out or runs the PR's code, only reads its metadata and calls the GitHub API (REVIEW §0). on: # zizmor: ignore[dangerous-triggers] no checkout, no PR code runs pull_request_target: - types: [opened, synchronize, reopened, ready_for_review] + types: [opened, reopened, synchronize] +# gh runs with the localstack-bot token: a merge made with GITHUB_TOKEN would start no workflows on +# main. GITHUB_TOKEN only lets fetch-metadata read the PR. permissions: - contents: read pull-requests: read -# A new push to the PR cancels the wait for the old commit. -concurrency: - group: dependabot-auto-merge-${{ github.event.pull_request.number }} - cancel-in-progress: true - jobs: auto-merge: - name: Merge when checks pass - # Both: the PR is Dependabot's, and Dependabot made this push, not someone pushing to its branch. - if: github.event.pull_request.user.login == 'dependabot[bot]' && github.actor == 'dependabot[bot]' + name: Approve and enable auto-merge + # The PR is Dependabot's, Dependabot made this push (not someone pushing to its branch), and this + # is not a fork. + if: >- + github.event.pull_request.user.login == 'dependabot[bot]' && + github.actor == 'dependabot[bot]' && + github.repository == 'localstack/localstack-mcp-server' runs-on: ubuntu-26.04 - # CI and the image smoke tests take about 10 minutes; leave room for queueing. - timeout-minutes: 90 + timeout-minutes: 5 steps: # Verifies the commits are Dependabot's own and reports the largest update in the PR (a group # reports its largest member). @@ -42,47 +38,17 @@ jobs: DEPS: ${{ steps.meta.outputs.dependency-names }} run: echo "::notice::Major update ($DEPS); not auto-merging." - - name: Wait for the checks + - name: Approve if: steps.meta.outputs.update-type != 'version-update:semver-major' env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.LOCALSTACK_BOT_TOKEN }} PR_URL: ${{ github.event.pull_request.html_url }} - SELF: ${{ github.workflow }} - REQUIRED: "build mcp-direct-tests mcp-tool-tests" - run: | - set -euo pipefail - # Give the PR's other workflows time to register their checks. - sleep 60 - while :; do - # gh exits non-zero while checks are pending or failing; the JSON is still printed. - checks=$(gh pr checks "$PR_URL" --json name,bucket,workflow || true) - others=$(jq --arg self "$SELF" '[.[] | select(.workflow != $self)]' <<<"${checks:-[]}") - failed=$(jq -r '.[] | select(.bucket == "fail" or .bucket == "cancel") | .name' <<<"$others") - if [ -n "$failed" ]; then - echo "::error::Checks failed, not merging: $(tr '\n' ' ' <<<"$failed")" - exit 1 - fi - missing="" - for name in $REQUIRED; do - jq -e --arg n "$name" 'any(.[]; .name == $n and .bucket == "pass")' <<<"$others" >/dev/null \ - || missing="$missing $name" - done - pending=$(jq '[.[] | select(.bucket == "pending")] | length' <<<"$others") - if [ -z "$missing" ] && [ "$pending" = 0 ]; then - echo "All checks passed." - break - fi - echo "Waiting: $pending pending; required not passed yet:${missing:- none}" - sleep 30 - done + run: gh pr review "$PR_URL" --approve - # The bot token, not GITHUB_TOKEN: a merge made with GITHUB_TOKEN starts no workflows, so the - # push to main would skip CI, the image push and the evals. --match-head-commit refuses to merge - # if the PR moved past the commit whose checks passed. - - name: Merge + # Merges once the main ruleset's required checks pass. + - name: Enable auto-merge if: steps.meta.outputs.update-type != 'version-update:semver-major' env: GH_TOKEN: ${{ secrets.LOCALSTACK_BOT_TOKEN }} PR_URL: ${{ github.event.pull_request.html_url }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - run: gh pr merge "$PR_URL" --squash --match-head-commit "$HEAD_SHA" + run: gh pr merge "$PR_URL" --auto --squash