diff --git a/.github/workflows/mirror-to-gitee.yml b/.github/workflows/mirror-to-gitee.yml new file mode 100644 index 0000000000..90ab9bd3b1 --- /dev/null +++ b/.github/workflows/mirror-to-gitee.yml @@ -0,0 +1,45 @@ +name: mirror-to-gitee + +on: [ push, pull_request ] + +jobs: + mirror-to-gitee: + if: ${{ (github.repository_owner == 'swoole') && (github.repository == 'swoole/swoole-cli') }} + runs-on: ubuntu-latest + steps: + - name: install deps + run: | + sudo apt install openssh-client git + + - name: Prepare Secret Key + env: + MIRROR_TO_GITEE_SECRET_KEY: ${{ secrets.MIRROR_TO_GITEE_SECRET_KEY }} + run: | + mkdir -p ~/.ssh/ + printf "%s\n" "$MIRROR_TO_GITEE_SECRET_KEY" > ~/.ssh/push-to-gitee-key + chmod 0400 ~/.ssh/push-to-gitee-key + cat > ~/.ssh/config <<'EOF' + Host gitee.com + Hostname gitee.com + Port 22 + PreferredAuthentications publickey + StrictHostKeyChecking no + IdentityFile ~/.ssh/push-to-gitee-key + EOF + ls -lh ~/.ssh/ + + - name: mirror to gitee with git mirror + run: | + set -x + + git clone --mirror https://github.com/swoole/swoole-cli.git swoole-cli + cd swoole-cli + git remote -v + + git remote set-url --push origin git@gitee.com:swoole/swoole-cli.git + git remote -v + + git fetch -p origin + git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin + + git push --mirror