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: |