dotnet-installer/.forgejo/workflows/mirror-repository.yml

34 lines
1.2 KiB
YAML

on:
workflow_dispatch:
schedule:
- cron: '@hourly'
jobs:
mirror:
name: Pull from upstream
runs-on: x86_64
container:
image: 'docker.io/node:20-bookworm'
steps:
- name: git mirror branches {v*/,}* & tags
run: |
git init --bare .
git remote add origin https://github.com/dotnet/installer
git fetch origin refs/heads/*:refs/mirror/*
git ls-remote origin refs/heads/v*/* | while read sha full_ref ; do
ref=${full_ref#refs/heads/}
git fetch origin $full_ref:refs/mirror/$ref
tag=${ref}
git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}*
done
if test "${{ vars.TEST }}" != true ; then
token=${{ secrets.CODE_FORGEJO_TOKEN }}
destination=${{ vars.DESTINATION }}
owner=${{ vars.OWNER }}
else
token=${{ secrets.TEST_FORGEJO_TOKEN }}
destination=${{ vars.TEST_DESTINATION }}
owner=${{ vars.TEST_OWNER }}
fi
git push --force https://any:$token@$destination/$owner/dotnet-installer refs/mirror/*:refs/heads/* refs/mirror-tags/*:refs/tags/* --tags