gitee-sync #48
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: gitee-sync | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| sync: | |
| name: gitee-sync | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| if: github.actor != 'dependabot[bot]' | |
| steps: | |
| - name: Checkout repository with full history | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure SSH key for Gitee | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.GITEE_PI_SSH }} | |
| - name: Sync processed branches to Gitee | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| branches=("main" "release/4.5.3") | |
| mkdir -p ~/.ssh | |
| ssh-keyscan -H gitee.com >> ~/.ssh/known_hosts | |
| git remote add gitee git@gitee.com:agoraio-community/API-Examples.git || \ | |
| git remote set-url gitee git@gitee.com:agoraio-community/API-Examples.git | |
| git fetch --no-tags origin "${branches[@]}" | |
| for branch in "${branches[@]}"; do | |
| work_branch="gitee-sync-${branch//\//-}" | |
| git checkout -B "${work_branch}" "origin/${branch}" | |
| ./.github/workflows/gitee-sync-shell.sh | |
| git push -f gitee "HEAD:refs/heads/${branch}" | |
| done | |
| git fetch --tags origin | |
| git push gitee --tags |