ci: add GitHub mirror job with disable option
Some checks failed
CI/CD / Test (push) Successful in 30s
CI/CD / Lint (push) Successful in 40s
CI/CD / Build (darwin-amd64) (push) Has been cancelled
CI/CD / Build (linux-amd64) (push) Has been cancelled
CI/CD / Build (darwin-arm64) (push) Has been cancelled
CI/CD / Build (linux-arm64) (push) Has been cancelled
CI/CD / Build & Push Docker Image (push) Has been cancelled
CI/CD / Release (push) Has been cancelled
CI/CD / Mirror to GitHub (push) Has been cancelled
CI/CD / Generate SBOM (push) Has been cancelled

This commit is contained in:
2025-12-13 11:22:44 +01:00
parent bbda6f3ed5
commit 0999795f65

View File

@@ -193,3 +193,29 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: goreleaser release --clean
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: alpine:latest
steps:
- name: Install git
run: apk add --no-cache git openssh-client
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GITHUB_MIRROR_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Clone and mirror
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/hmac-file-server.git
git push --mirror github || git push --force --all github && git push --force --tags github