ci: fix LMSYS blog sync to open a PR via gh and only run on main (#27179)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
zijiexia
2026-06-04 16:47:46 -07:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 448d3afb76
commit 47377525cb
+24 -4
View File
@@ -7,9 +7,11 @@ on:
permissions:
contents: write
pull-requests: write
jobs:
sync:
if: github.repository == 'sgl-project/sglang' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Check out repository
@@ -25,16 +27,34 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python docs_new/scripts/update_lmsys_sglang_blogs.py
- name: Commit and push changes
- name: Open or update pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if git diff --quiet -- docs_new/index.mdx; then
echo "No blog card changes to commit."
echo "No blog card changes; nothing to do."
exit 0
fi
BRANCH="auto/lmsys-blog-cards"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Recreate the bot branch as "current main + card diff" and overwrite
# any previous state, so the PR always shows a clean single-commit diff.
git checkout -B "$BRANCH"
git add docs_new/index.mdx
git diff --cached --quiet && exit 0
git commit -m "docs: sync LMSYS SGLang blog cards"
git push
git push --force origin "$BRANCH"
# Open a PR only if one is not already open for this branch; otherwise
# the force-push above has already updated the existing PR in place.
if [ -z "$(gh pr list --head "$BRANCH" --base main --state open --json number --jq '.[].number')" ]; then
gh pr create \
--base main \
--head "$BRANCH" \
--title "docs: sync LMSYS SGLang blog cards" \
--body 'Automated sync of the LMSYS SGLang blog cards in `docs_new/index.mdx`, opened by the `Sync LMSYS SGLang blogs` workflow.'
fi