-
Notifications
You must be signed in to change notification settings - Fork 0
Mirroring an External Repository
Research or teaching work hosted outside the organisation, for example on a personal account or a collaborator's account, should be mirrored here where the department retains an interest in it. A mirror is a copy kept up to date with the upstream repository. It is not a fork: a fork is for proposing changes or starting a new line of development, whereas a mirror simply tracks the original.
For an occasional copy:
git clone --mirror https://github.com/UPSTREAM_OWNER/REPO.git
cd REPO.git
git remote set-url --push origin https://github.com/uct-eee-department/REPO.git
git push --mirrorRepeat the final push whenever you want to update the mirror.
To keep a mirror in sync automatically, add a scheduled workflow to the upstream repository. A minimal example, saved as .github/workflows/mirror.yml:
name: Mirror to organisation
on:
push:
schedule:
- cron: '0 3 * * 0'
workflow_dispatch:
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to mirror
run: |
git push --mirror https://x-access-token:${{ secrets.MIRROR_TOKEN }}@github.com/uct-eee-department/REPO.gitThis needs a token with write access to the organisation repository, stored as a repository secret named MIRROR_TOKEN. Adjust the schedule to suit. Note that git push --mirror makes the target match the source exactly, including deleting refs that no longer exist upstream, which is what keeps a true mirror in step.