From ca4664522dfbe02f52e8c8fb4f0a839ede3f70a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Mon, 11 Aug 2025 11:54:24 +0800 Subject: [PATCH] Create assets.yml --- .github/workflows/assets.yml | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/assets.yml diff --git a/.github/workflows/assets.yml b/.github/workflows/assets.yml new file mode 100644 index 000000000..c98e18a01 --- /dev/null +++ b/.github/workflows/assets.yml @@ -0,0 +1,63 @@ +name: Sync Assets to Private B Repo +on: + push: + branches: [ main ] + workflow_dispatch: # 支持手动触发 + +jobs: + sync: + runs-on: ubuntu-latest + steps: + # 步骤1:拉取 A 仓库代码 + - name: Checkout A Repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # 步骤2:准备同步文件 + - name: Prepare files for B Repo + run: | + mkdir -p temp-b-repo/out/assets + + # 校验并复制需要同步的资产目录 + if [ -d "common/data/xml/assets" ]; then + # 复制assets目录下的所有内容到目标out/assets目录 + cp -r common/data/xml/assets/* temp-b-repo/out/assets/ + else + echo "Error: common/data/xml/assets directory not found!" && exit 1 + fi + + # 步骤3:推送到私有 B 仓库 + - name: Push to Private B Repo + env: + B_REPO_TOKEN: ${{ secrets.B_REPO_TOKEN }} + B_REPO_URL: https://github.com/TO-teams/flash.git + B_BRANCH: main + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + # 克隆B仓库(如果尚未克隆) + if [ ! -d "b-repo" ]; then + git clone https://$B_REPO_TOKEN@github.com/TO-teams/flash.git b-repo + fi + + cd b-repo + git checkout $B_BRANCH + git pull origin $B_BRANCH + + # 确保目标目录存在 + mkdir -p out/assets + + # 复制准备好的文件 + cp -r ../temp-b-repo/out/assets/* out/assets/ + + # 检查是否有变更 + if git diff --quiet; then + echo "No changes to sync to B repo." + else + git add out/assets + git commit -m "Sync assets: $(date +'%Y-%m-%d %H:%M:%S')" + git push https://$B_REPO_TOKEN@github.com/TO-teams/flash.git $B_BRANCH + fi +