forgejo/.forgejo/workflows/mirror.yml
Earl Warren 1501294af0
All checks were successful
/ publish (push) Successful in 12s
/ mirror (push) Successful in 39s
mirror hourly instead of daily
a 24h delay may not be such a good idea when relying ont this mirror
for security releases
2024-03-28 09:03:15 +01:00

27 lines
870 B
YAML

on:
schedule:
- cron: '@hourly'
push:
branches:
- 'main'
jobs:
mirror:
runs-on: docker
container:
image: 'docker.io/node:20-bookworm'
steps:
- name: git mirror branches {v*/,}forgejo & tags
run: |
git init --bare .
git remote add origin https://codeberg.org/forgejo/forgejo
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
tag=${ref%/forgejo}
git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}*
done
git push --force https://any:$GITHUB_TOKEN@code.forgejo.org/${{ env.GITHUB_REPOSITORY }} refs/mirror/*:refs/heads/* refs/mirror-tags/*:refs/tags/*