diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6af65af..a3128a6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -187,3 +187,26 @@ jobs: ${TAGS} \ . # Test 1765481480 + + mirror: + name: Mirror to GitHub + runs-on: ubuntu-latest + needs: [test, lint] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && vars.MIRROR_ENABLED != 'false' + container: + image: debian:bookworm-slim + volumes: + - /root/.ssh:/root/.ssh:ro + steps: + - name: Install git + run: apt-get update && apt-get install -y --no-install-recommends git openssh-client ca-certificates && rm -rf /var/lib/apt/lists/* + + - name: Clone and mirror + env: + GIT_SSH_COMMAND: "ssh -i /root/.ssh/id_ed25519 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git clone --mirror ${{ env.GITEA_URL }}/${GITHUB_REPOSITORY}.git repo.git + cd repo.git + git remote add github git@github.com:PlusOne/dbbackup.git + git push --mirror github || git push --force --all github && git push --force --tags github