From 9ec494664c5228b665c300a2e887e066df5ed037 Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 19 Dec 2025 16:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E9=95=9C=E5=83=8F=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E5=90=8C=E6=AD=A5=20workflow=20(#5004)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cnb.yml | 18 ------------------ .github/workflows/gitee.yml | 21 --------------------- .github/workflows/mirror.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 3 +++ 4 files changed, 32 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/cnb.yml delete mode 100644 .github/workflows/gitee.yml create mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/cnb.yml b/.github/workflows/cnb.yml deleted file mode 100644 index fad05f65f..000000000 --- a/.github/workflows/cnb.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Sync to CNB - -on: - push - -jobs: - run: - if: ${{ github.repository == 'HMCL-dev/HMCL' }} - runs-on: ubuntu-latest - steps: - - name: Mirror GitHub to CNB - env: - SOURCE_REPO: HMCL-dev/HMCL - TARGET_REPO: HMCL-dev/HMCL - run: | - git clone --mirror "https://github.com/$SOURCE_REPO.git" -- repo - cd repo - git push -f --prune "https://${{ secrets.CNB_SYNC_USERNAME }}:${{ secrets.CNB_SYNC_TOKEN }}@cnb.cool/$TARGET_REPO.git" "refs/heads/*:refs/heads/*" "refs/tags/*:refs/tags/*" diff --git a/.github/workflows/gitee.yml b/.github/workflows/gitee.yml deleted file mode 100644 index fb0660c49..000000000 --- a/.github/workflows/gitee.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Sync to Gitee - -on: - push - -jobs: - run: - if: ${{ github.repository_owner == 'HMCL-dev' }} - runs-on: ubuntu-latest - steps: - - name: Mirror GitHub to Gitee - uses: Yikun/hub-mirror-action@v1.4 - with: - src: github/HMCL-dev - dst: gitee/huanghongxun - static_list: 'HMCL' - force_update: true - debug: true - dst_key: ${{ secrets.GITEE_SYNC_BOT_PRIVATE_KEY }} - dst_token: ${{ secrets.GITEE_SYNC_BOT_TOKEN }} - cache_path: /github/workspace/hub-mirror-cache diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 000000000..6a38683fd --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1,29 @@ +name: Mirror Repository + +on: + workflow_dispatch: + workflow_call: + push: + +jobs: + mirror: + strategy: + matrix: + target: + - name: Gitee + repo: gitee.com/huanghongxun/HMCL + user: 'GITEE_SYNC_USERNAME' + token: 'GITEE_SYNC_TOKEN' + - name: CNB + repo: cnb.cool/HMCL-dev/HMCL + user: 'CNB_SYNC_USERNAME' + token: 'CNB_SYNC_TOKEN' + name: Mirror to ${{ matrix.target.name }} + if: ${{ github.repository == 'HMCL-dev/HMCL' }} + runs-on: ubuntu-latest + steps: + - name: Mirror GitHub to ${{ matrix.target.name }} + run: | + git clone --mirror "https://github.com/$GITHUB_REPOSITORY.git" -- repo + cd repo + git push -f --prune "https://${{ secrets[matrix.target.user] }}:${{ secrets[matrix.target.token] }}@${{ matrix.target.repo }}.git" "refs/heads/*:refs/heads/*" "refs/tags/*:refs/tags/*" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dad921040..dcaac40ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -97,6 +97,9 @@ jobs: run: go install "cnb.cool/looc/git-cnb@$GIT_CNB_VERSION" env: GIT_CNB_VERSION: '1.1.2' + - name: Update mirror repositories + if: ${{ env.continue == 'true' }} + uses: ./.github/workflows/mirror.yml - name: Create CNB release if: ${{ env.continue == 'true' }} run: |