0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 15:23:14 -05:00
forgejo/.forgejo/workflows/mirror.yml
Earl Warren d07c5cf69c
fix: actions move to data.forgejo.org
code.forgejo.org is meant for development, the actions need to be
highly available and can be read-only. This is what data.forgejo.org
will provide.
2024-12-19 10:55:05 +01:00

27 lines
946 B
YAML

name: mirror
on:
workflow_dispatch:
schedule:
- cron: '@daily'
jobs:
mirror:
if: ${{ secrets.MIRROR_TOKEN != '' }}
runs-on: docker
container:
image: 'data.forgejo.org/oci/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/}
echo git fetch origin $full_ref:refs/mirror/$ref
git fetch origin $full_ref:refs/mirror/$ref
done
echo git push --force https://${{ vars.MIRROR_DESTINATION }} refs/mirror/*:refs/heads/*
git push --force https://any:${{ secrets.MIRROR_TOKEN }}@${{ vars.MIRROR_DESTINATION }} refs/mirror/*:refs/heads/*