From 241d7d142e2a855e71118ad67700e8d5da2b84b5 Mon Sep 17 00:00:00 2001 From: Lovehsigure_520 <62863834+Neko-233@users.noreply.github.com> Date: Fri, 22 May 2026 15:53:57 +0800 Subject: [PATCH] chore(ci): auto-merge sponsors updates (#1850) --- .github/workflows/sponsors-svg.yml | 34 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sponsors-svg.yml b/.github/workflows/sponsors-svg.yml index 4df1c06ee..cef3759d7 100644 --- a/.github/workflows/sponsors-svg.yml +++ b/.github/workflows/sponsors-svg.yml @@ -36,9 +36,12 @@ jobs: - name: Generate sponsors svg run: pnpm run sponsors:generate + - name: Remove private SponsorKit cache + run: rm -f docs/content/public/assets/sponsors/.cache.json + - name: Create or update sponsors PR env: - GH_TOKEN: ${{ secrets.PAT_SLASH_COMMAND_DISPATCH || github.token }} + GH_TOKEN: ${{ secrets.PAT_SLASH_COMMAND_DISPATCH }} SPONSORS_BRANCH: automation/update-sponsors-svg run: | if [ -z "$(git status --porcelain -- docs/content/public/assets/sponsors)" ]; then @@ -46,26 +49,45 @@ jobs: exit 0 fi + if [ -z "$GH_TOKEN" ]; then + echo "::error::PAT_SLASH_COMMAND_DISPATCH is required so generated sponsors PRs trigger required checks." + exit 1 + fi + git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" git fetch origin "${SPONSORS_BRANCH}:refs/remotes/origin/${SPONSORS_BRANCH}" || true git checkout -B "$SPONSORS_BRANCH" - git add docs/content/public/assets/sponsors + git add docs/content/public/assets/sponsors/sponsors.json docs/content/public/assets/sponsors/sponsors.svg git commit -m "chore: update sponsors svg" git push --force-with-lease origin "$SPONSORS_BRANCH" - if gh pr view "$SPONSORS_BRANCH" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then - gh pr edit "$SPONSORS_BRANCH" \ + PR_NUMBER="$(gh pr list \ + --repo "$GITHUB_REPOSITORY" \ + --head "$SPONSORS_BRANCH" \ + --state open \ + --json number \ + --jq '.[0].number // empty')" + + if [ -n "$PR_NUMBER" ]; then + gh pr edit "$PR_NUMBER" \ --repo "$GITHUB_REPOSITORY" \ --title "chore: update sponsors svg" \ --body "This PR updates generated SponsorKit assets from the scheduled sponsors workflow." + PR_TARGET="$PR_NUMBER" else - gh pr create \ + PR_TARGET="$(gh pr create \ --repo "$GITHUB_REPOSITORY" \ --base main \ --head "$SPONSORS_BRANCH" \ --title "chore: update sponsors svg" \ - --body "This PR updates generated SponsorKit assets from the scheduled sponsors workflow." + --body "This PR updates generated SponsorKit assets from the scheduled sponsors workflow.")" fi + + gh pr merge "$PR_TARGET" \ + --repo "$GITHUB_REPOSITORY" \ + --auto \ + --squash \ + --delete-branch