Skip to content

chore: update bailian-docs-llm-wiki (2026-07-30) #3

chore: update bailian-docs-llm-wiki (2026-07-30)

chore: update bailian-docs-llm-wiki (2026-07-30) #3

name: auto-merge-to-main
# The FC crawler pushes skill updates to feat/bailian-docs-update.
# On each such push, create (or reuse) a PR to main and merge it.
# The resulting push to main then triggers publish-skills.yml,
# which pokes the remote FC to sync main -> OSS.
on:
push:
branches: [feat/bailian-docs-update]
paths: ['skills/**']
permissions:
contents: write
pull-requests: write
concurrency:
group: auto-merge-to-main
cancel-in-progress: false
jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync main back into branch (prevent squash-merge conflicts)
run: |
# Squash-merging PRs rewrites history on main, so this branch
# diverges from main after every merge and later PRs conflict.
# Merge main back in first. Conflicts are resolved by ownership:
# - skills/bailian-docs-llm-wiki/** : crawler output wins (ours)
# - everything else : main wins (theirs), since
# humans edit other skills and repo files on main.
# Pushing with the default GITHUB_TOKEN does NOT retrigger this
# workflow (recursive triggers are suppressed), so no loop.
BRANCH="${{ github.ref_name }}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin main
if git merge-base --is-ancestor origin/main HEAD; then
echo "Branch already contains main, nothing to sync."
exit 0
fi
if ! git merge --no-edit origin/main; then
echo "Resolving conflicts by path ownership..."
git diff --name-only --diff-filter=U -z |
while IFS= read -r -d '' f; do
case "$f" in
skills/bailian-docs-llm-wiki/*) side=2; flag=--ours ;;
*) side=3; flag=--theirs ;;
esac
# side present in index -> take that version; absent -> it was
# deleted on the winning side, so delete the file.
if git ls-files -u -- "$f" | awk '{print $3}' | grep -qx "$side"; then
git checkout "$flag" -- "$f"
git add -- "$f"
else
git rm -f --quiet -- "$f"
fi
done
git commit --no-edit
fi
git push origin "HEAD:${BRANCH}"
- name: Create or update PR to main
id: pr
env:
GH_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
BRANCH="${{ github.ref_name }}"
# Use the latest commit subject as the PR title (fallback to default title)
TITLE=$(git log -1 --pretty=%s "${{ github.sha }}")
[ -n "$TITLE" ] || TITLE="chore: update bailian-docs-llm-wiki ($(TZ=Asia/Shanghai date +%Y-%m-%d))"
EXISTING_PR=$(gh pr list --head "$BRANCH" --base main --state open --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then
echo "PR #$EXISTING_PR already exists, updating..."
# gh pr edit uses GraphQL and needs read:org scope; the REST
# endpoint only needs repo scope, which GIT_TOKEN has.
gh api "repos/${{ github.repository }}/pulls/$EXISTING_PR" \
-X PATCH -f title="$TITLE" --silent
PR_NUMBER="$EXISTING_PR"
else
echo "Creating new PR..."
PR_URL=$(gh pr create \
--base main \
--head "$BRANCH" \
--title "$TITLE" \
--body "Automated PR created on push to \`${BRANCH}\`." \
--no-maintainer-edit)
# gh pr create prints the PR URL; keep only the trailing number
PR_NUMBER="${PR_URL##*/}"
fi
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
- name: Auto-merge PR
env:
# GIT_TOKEN is a classic PAT (repo scope, no expiration) so that
# the merge commit fires publish-skills.yml on main.
GH_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
PR_NUMBER="${{ steps.pr.outputs.number }}"
echo "Merging PR #$PR_NUMBER..."
gh pr merge "$PR_NUMBER" --squash --delete-branch=false
echo "### PR #$PR_NUMBER merged" >> "$GITHUB_STEP_SUMMARY"
echo "Branch \`${{ github.ref_name }}\` has been merged into \`main\`." >> "$GITHUB_STEP_SUMMARY"