update mirror action

This commit is contained in:
whyour 2026-05-31 15:04:10 +08:00
parent 0e5b8bef4b
commit b6537e27ef

View File

@ -21,14 +21,16 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: Yikun/hub-mirror-action@master - name: Push to GitLab
with: run: |
src: github/whyour set +e
dst: gitlab/whyour mkdir -p ~/.ssh
dst_key: ${{ secrets.GITLAB_SSH_PK }} printf '%s\n' "${{ secrets.GITLAB_SSH_PK }}" > ~/.ssh/id_rsa
dst_token: ${{ secrets.GITLAB_TOKEN }} chmod 600 ~/.ssh/id_rsa
static_list: "qinglong" ssh-keyscan -T 10 gitlab.com >> ~/.ssh/known_hosts 2>/dev/null
force_update: true git remote add gitlab git@gitlab.com:whyour/qinglong.git 2>/dev/null
git push --force --all gitlab 2>&1 || echo "::warning::GitLab push failed"
git push --force --tags gitlab 2>&1 || echo "::warning::GitLab tags push failed"
code_gitee: code_gitee:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -36,7 +38,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup SSH and push to Gitee - name: Push to Gitee
env: env:
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
run: | run: |
@ -50,24 +52,15 @@ jobs:
if git push --force --all gitee 2>&1; then if git push --force --all gitee 2>&1; then
echo "::notice::Gitee push --all succeeded" echo "::notice::Gitee push --all succeeded"
else else
echo "::warning::Push --all failed, trying to create repo via API..." echo "::warning::Push failed, trying to create repo via API..."
curl -sS --connect-timeout 30 --max-time 60 \ curl -sS --connect-timeout 30 --max-time 60 \
-X POST "https://gitee.com/api/v5/user/repos" \ -X POST "https://gitee.com/api/v5/user/repos" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"name":"qinglong","private":"false"}' \ -d '{"name":"qinglong","private":"false"}' \
"?access_token=$GITEE_TOKEN" 2>/dev/null "?access_token=$GITEE_TOKEN" 2>/dev/null
if git push --force --all gitee 2>&1; then git push --force --all gitee 2>&1 && echo "::notice::Gitee push succeeded after repo creation" || echo "::warning::Gitee push failed after retry"
echo "::notice::Gitee push --all succeeded after repo creation"
else
echo "::warning::Gitee push --all failed after retry"
fi
fi
if git push --force --tags gitee 2>&1; then
echo "::notice::Gitee push --tags succeeded"
else
echo "::warning::Gitee push --tags failed"
fi fi
git push --force --tags gitee 2>&1 || echo "::warning::Gitee tags push failed"
build-static: build-static:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -106,34 +99,48 @@ jobs:
needs: build-static needs: build-static
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6 - name: Push qinglong-static to GitLab
with: run: |
fetch-depth: 0 set +e
- uses: Yikun/hub-mirror-action@master mkdir -p ~/.ssh
with: printf '%s\n' "${{ secrets.GITLAB_SSH_PK }}" > ~/.ssh/id_rsa
src: github/whyour chmod 600 ~/.ssh/id_rsa
dst: gitlab/whyour ssh-keyscan -T 10 gitlab.com >> ~/.ssh/known_hosts 2>/dev/null
dst_key: ${{ secrets.GITLAB_SSH_PK }} git clone --depth=1 --single-branch https://github.com/whyour/qinglong-static.git static-mirror
dst_token: ${{ secrets.GITLAB_TOKEN }} cd static-mirror
static_list: "qinglong-static" git remote add gitlab git@gitlab.com:whyour/qinglong-static.git 2>/dev/null
force_update: true git push --force --all gitlab 2>&1 || echo "::warning::GitLab static push failed"
git push --force --tags gitlab 2>&1 || echo "::warning::GitLab static tags push failed"
static_gitee: static_gitee:
needs: build-static needs: build-static
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Setup SSH - name: Push qinglong-static to Gitee
env:
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
run: | run: |
set +e
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.GITLAB_SSH_PK }}" > ~/.ssh/id_rsa printf '%s\n' "${{ secrets.GITLAB_SSH_PK }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com gitee.com >> ~/.ssh/known_hosts ssh-keyscan -T 10 gitee.com >> ~/.ssh/known_hosts 2>/dev/null
- name: Mirror qinglong-static to Gitee git clone --depth=1 --single-branch https://github.com/whyour/qinglong-static.git static-mirror
run: |
git clone --mirror https://github.com/whyour/qinglong-static.git static-mirror
cd static-mirror cd static-mirror
git remote set-url origin git@gitee.com:whyour/qinglong-static.git git remote add gitee git@gitee.com:whyour/qinglong-static.git 2>/dev/null
git push --force --mirror
if git push --force --all gitee 2>&1; then
echo "::notice::Gitee static push succeeded"
else
echo "::warning::Push failed, trying to create repo via API..."
curl -sS --connect-timeout 30 --max-time 60 \
-X POST "https://gitee.com/api/v5/user/repos" \
-H "Content-Type: application/json" \
-d '{"name":"qinglong-static","private":"false"}' \
"?access_token=$GITEE_TOKEN" 2>/dev/null
git push --force --all gitee 2>&1 && echo "::notice::Gitee static push succeeded after repo creation" || echo "::warning::Gitee static push failed after retry"
fi
git push --force --tags gitee 2>&1 || echo "::warning::Gitee static tags push failed"
build-alpine: build-alpine:
if: ${{ !startsWith(github.ref, 'refs/tags/') }} if: ${{ !startsWith(github.ref, 'refs/tags/') }}
@ -191,6 +198,8 @@ jobs:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v4 uses: docker/setup-qemu-action@v4
with:
cache-image: false
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4 uses: docker/setup-buildx-action@v4
@ -267,6 +276,8 @@ jobs:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v4 uses: docker/setup-qemu-action@v4
with:
cache-image: false
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4 uses: docker/setup-buildx-action@v4
@ -329,6 +340,8 @@ jobs:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v4 uses: docker/setup-qemu-action@v4
with:
cache-image: false
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4 uses: docker/setup-buildx-action@v4
@ -392,6 +405,8 @@ jobs:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v4 uses: docker/setup-qemu-action@v4
with:
cache-image: false
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4 uses: docker/setup-buildx-action@v4