update #208
This file contains 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: push to gitee | |
on: | |
push: | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
push-to-gitee: | |
if: ${{ (github.repository_owner == 'jingjingxyk') && (github.repository == 'jingjingxyk/swoole-cli') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: install deps | |
run: | | |
sudo apt install openssh-client | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set Env | |
run: | | |
echo "CURRENT_BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV | |
- name: Prepare Secret Key | |
env: | |
PUSH_TO_GITEE_SECRET_KEY: ${{ secrets.PUSH_TO_GITEE_SECRET_KEY }} | |
run: | | |
mkdir -p ~/.ssh/ | |
printf "%s\n" "$PUSH_TO_GITEE_SECRET_KEY" > ~/.ssh/swoole-cli-github-push-to-gitee-key | |
chmod 0400 ~/.ssh/swoole-cli-github-push-to-gitee-key | |
cat > ~/.ssh/config <<'EOF' | |
Host gitee.com | |
Hostname gitee.com | |
Port 22 | |
PreferredAuthentications publickey | |
StrictHostKeyChecking no | |
IdentityFile ~/.ssh/swoole-cli-github-push-to-gitee-key | |
EOF | |
ls -lh ~/.ssh/ | |
- name: push to gitee with git mirror | |
run: | | |
set -x | |
CURRENT_DIR=$(pwd) | |
ls -lha . | |
# 参考 https://github.com/wearerequired/git-mirror-action/blob/master/git-mirror.sh | |
git remote -v | |
git clone --mirror https://github.com/jingjingxyk/swoole-cli swoole-cli | |
cd swoole-cli | |
pwd | |
# git remote set-url --push origin "$DESTINATION_REPO" | |
git remote set-url --push origin git@gitee.com:jingjingxyk/swoole-cli.git | |
git remote -v | |
git fetch -p origin | |
# Exclude refs created by GitHub for pull request. | |
git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin | |
git push --mirror | |
cd ${CURRENT_DIR} | |
# git clone --mirror git@gitee.com:jingjingxyk/swoole-cli.git swoole-cli | |
# cd swoole-cli | |
# git remote set-url --push git@gitee.com:jingjingxyk/swoole-cli.git | |
# git remote -v | |
# git fetch -p origin | |
# Exclude refs created by GitHub for pull request. | |
# git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin | |
# git push --mirror | |