From 644f7cb7338ae09b5ea7021132e93c70ba8fc771 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 4 Jan 2024 17:48:46 +0100 Subject: [PATCH] [CI] push forgejo branches to the specified destination (cherry picked from commit 22abd100cbab75673c53e4fb36fa574ada660aee) (cherry picked from commit 4e2c30cb5bcd7a4e2b2385a774062492e741a9e9) (cherry picked from commit 1ddc08747c8819e8967c95d54d3e273ef3831570) (cherry picked from commit ba3df0131412c2eb41a3312558bc4df5881caad5) --- .forgejo/workflows/mirror.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .forgejo/workflows/mirror.yml diff --git a/.forgejo/workflows/mirror.yml b/.forgejo/workflows/mirror.yml new file mode 100644 index 0000000000..fd419be49d --- /dev/null +++ b/.forgejo/workflows/mirror.yml @@ -0,0 +1,25 @@ +name: mirror + +on: + push: + branches: + - 'forgejo' + - 'v*/forgejo' + +jobs: + mirror: + if: ${{ secrets.MIRROR_TOKEN != '' }} + runs-on: docker + container: + image: 'docker.io/node:20-bookworm' + steps: + - name: git push {v*/,}forgejo + run: | + git init --bare . + git remote add origin ${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }} + git fetch origin refs/heads/forgejo:refs/mirror/forgejo + git ls-remote origin refs/heads/v*/forgejo | while read sha full_ref ; do + ref=${full_ref#refs/heads/} + git fetch origin $full_ref:refs/mirror/$ref + done + git push --force https://any:${{ secrets.MIRROR_TOKEN }}@${{ vars.MIRROR_DESTINATION }} refs/mirror/*:refs/heads/*