chore(ci): auto-merge sponsors updates (#1850)

This commit is contained in:
Lovehsigure_520
2026-05-22 15:53:57 +08:00
committed by GitHub
parent 3828d06322
commit 241d7d142e
+28 -6
View File
@@ -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