docs: update README_HF #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Demo Branch | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| sync-demo: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create demo branch if it doesn't exist | |
| run: | | |
| if ! git ls-remote --heads origin demo | grep -q demo; then | |
| echo "Creating demo branch..." | |
| git checkout -b demo | |
| git push origin demo | |
| else | |
| echo "Demo branch already exists" | |
| fi | |
| - name: Checkout demo branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: demo | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| path: demo | |
| - name: Clean demo directory | |
| run: | | |
| cd demo | |
| # 删除所有文件/文件夹,但保留 .git | |
| find . -mindepth 1 -path './.git' -prune -o -exec rm -rf {} + 2>/dev/null || true | |
| - name: Copy files using config | |
| run: | | |
| yq eval '.sync[] | .source + ":" + .dest' .github/sync-config.yml | while IFS=: read -r src dst; do | |
| src=$(echo "$src" | xargs) | |
| dst=$(echo "$dst" | xargs) | |
| [ -z "$src" ] && continue | |
| if [ -e "$src" ]; then | |
| target_path="demo/$dst" | |
| if [[ "$dst" == */ ]] || [ -d "$src" ]; then | |
| mkdir -p "$target_path" | |
| cp -r "$src" "$target_path" | |
| echo "Copied $src → $target_path" | |
| else | |
| mkdir -p "$(dirname "$target_path")" | |
| cp "$src" "$target_path" | |
| echo "Copied $src → $target_path" | |
| fi | |
| else | |
| echo "Source not found: $src" | |
| fi | |
| done | |
| - name: Commit and push changes | |
| run: | | |
| cd demo | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "github-actions[bot]" | |
| # 检查是否有变化 | |
| if [[ -n $(git status --porcelain) ]]; then | |
| git add . | |
| git commit -m "Auto-sync demo branch with main branch" | |
| git push origin demo | |
| echo "Changes pushed to demo branch" | |
| else | |
| echo "No changes to sync" | |
| fi | |
| push-hf: | |
| needs: sync-demo | |
| uses: ./.github/workflows/push-to-hf.yml | |
| secrets: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} |