更新 README.md #11
Workflow file for this run
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 Open Source Mirror | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| sync-opensource: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Private Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| path: private-repo | |
| - name: Checkout Public Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Jamailar/RedBox | |
| token: ${{ secrets.PUBLIC_REPO_TOKEN }} | |
| path: public-repo | |
| - name: Sync Files | |
| run: | | |
| set -euo pipefail | |
| sync_dir() { | |
| local src="$1" | |
| local dst="$2" | |
| if [ -d "$src" ]; then | |
| mkdir -p "$dst" | |
| rsync -av --delete "$src"/ "$dst"/ | |
| else | |
| echo "Source missing: $src, removing target: $dst" | |
| rm -rf "$dst" | |
| fi | |
| } | |
| # 仅同步代码与 README(以及 README 依赖图片) | |
| cp private-repo/README.md public-repo/ | |
| cp private-repo/LICENSE public-repo/ | |
| sync_dir private-repo/desktop public-repo/desktop | |
| sync_dir private-repo/scripts public-repo/scripts | |
| sync_dir private-repo/images public-repo/images | |
| # Plugin 不开源:强制移除 | |
| rm -rf public-repo/Plugin | |
| - name: Commit and Push to Public Repo | |
| run: | | |
| set -euo pipefail | |
| cd public-repo | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to sync" | |
| exit 0 | |
| fi | |
| git commit -m "chore: sync open-source mirror from ${{ github.ref_name }}" | |
| git push |