From 4bfe60a28a79e50d97d8b5951000456f078f4057 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Tue, 15 Sep 2026 02:28:33 +0200 Subject: [PATCH] ci: split dependabot groups and auto-merge ecosystem updates Every production-dependencies PR for the last ten cycles was closed unmerged. The group matched '*', so first-party @quartz-community/* updates were bundled with third-party churn and could not land independently while CI was red. Splits first-party packages into a quartz-ecosystem group and excludes them from production-dependencies, so ecosystem updates land on their own. Adds an auto-merge workflow for that group only. GitHub auto-merge is disabled on this repository and v5 has no branch protection, so the workflow gates itself: it runs only after Build and Test succeeds, independently verifies that every check run on the commit succeeded, refuses major bumps, and only then squash-merges. --- .github/dependabot.yml | 9 +++ .github/workflows/dependabot-automerge.yaml | 82 +++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 .github/workflows/dependabot-automerge.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f73eb96..be5ef47 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,10 +5,19 @@ updates: schedule: interval: "weekly" groups: + # Separated so a risky third-party major cannot block ecosystem updates. + quartz-ecosystem: + applies-to: "version-updates" + patterns: + - "@quartz-community/*" + - "@quartz-themes/*" production-dependencies: applies-to: "version-updates" patterns: - "*" + exclude-patterns: + - "@quartz-community/*" + - "@quartz-themes/*" - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.github/workflows/dependabot-automerge.yaml b/.github/workflows/dependabot-automerge.yaml new file mode 100644 index 0000000..74fa38c --- /dev/null +++ b/.github/workflows/dependabot-automerge.yaml @@ -0,0 +1,82 @@ +name: Dependabot Auto-merge + +on: + workflow_run: + workflows: ["Build and Test"] + types: [completed] + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + if: >- + github.repository == 'jackyzha0/quartz' && + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.actor.login == 'dependabot[bot]' && + contains(github.event.workflow_run.head_branch, 'quartz-ecosystem') + runs-on: ubuntu-latest + steps: + - name: Resolve pull request + id: pr + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + run: | + set -euo pipefail + number=$(gh pr list --state open --json number,headRefOid \ + --jq "map(select(.headRefOid == \"${HEAD_SHA}\")) | .[0].number // empty") + if [ -z "$number" ]; then + echo "No open PR matches ${HEAD_SHA}; nothing to merge." + echo "found=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + echo "number=${number}" >> "$GITHUB_OUTPUT" + echo "found=true" >> "$GITHUB_OUTPUT" + + - name: Require every check on the commit to have succeeded + if: steps.pr.outputs.found == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + run: | + set -euo pipefail + runs=$(gh api "repos/${GH_REPO}/commits/${HEAD_SHA}/check-runs" --paginate \ + --jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "")"') + echo "$runs" + bad=$(printf '%s\n' "$runs" | awk -F'\t' ' + $2 != "completed" { print; next } + $3 != "success" && $3 != "neutral" && $3 != "skipped" { print } + ') + if [ -n "$bad" ]; then + echo "Refusing to merge - not all checks succeeded:" + printf '%s\n' "$bad" + exit 1 + fi + + - name: Confirm update is not a major bump + if: steps.pr.outputs.found == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ steps.pr.outputs.number }} + run: | + set -euo pipefail + title=$(gh pr view "$PR_NUMBER" --json title --jq .title) + echo "PR title: $title" + if printf '%s' "$title" | grep -qiE 'major'; then + echo "Refusing to merge a major update; needs human review." + exit 1 + fi + + - name: Merge + if: steps.pr.outputs.found == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ steps.pr.outputs.number }} + run: gh pr merge "$PR_NUMBER" --squash --delete-branch