# HG changeset patch # User Sebastien Jodogne # Date 1786085320 -7200 # Node ID efe74c6e32f8ace04c7b1e400323bd811e0cf6b5 # Parent c8cb5bd6a149656bed884e7ea147edb868fd67eb added github action to mirror from mercurial diff -r c8cb5bd6a149 -r efe74c6e32f8 .github/workflows/mirror.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.github/workflows/mirror.yml Fri Aug 07 08:48:40 2026 +0200 @@ -0,0 +1,52 @@ +name: Mirror Mercurial to GitHub + +env: + HG_SOURCE_URL: https://orthanc.uclouvain.be/hg/orthanc-neuro/ + GITHUB_TARGET: jodogne/mirror-orthanc-neuro.git + FAST_EXPORT_VERSION: fast-export-260405 + +on: + schedule: + - cron: '40 2 * * *' + workflow_dispatch: {} + +concurrency: + group: hg-mirror + cancel-in-progress: false + +permissions: + contents: write # GITHUB_TOKEN is read-only by default; this grants push access + +jobs: + mirror: + runs-on: ubuntu-slim + steps: + - name: Install Mercurial and fast-export + run: | + sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y mercurial git wget + cd /tmp/ + wget https://orthanc.uclouvain.be/downloads/third-party-downloads/${FAST_EXPORT_VERSION}.tar.gz + tar xvf ${FAST_EXPORT_VERSION}.tar.gz + + - name: Full clone of Mercurial source + run: | + hg clone "${HG_SOURCE_URL}" hg-repo + + - name: Full conversion (fresh git repo every run) + run: | + git init --bare git-repo + cd git-repo + /tmp/${FAST_EXPORT_VERSION}/hg-fast-export.sh -r ../hg-repo --hg-hash --hgtags + + - name: Push (never force, so it can't rewrite or delete history) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd git-repo + git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_TARGET}" + git push origin 'refs/heads/*:refs/heads/*' + git push origin 'refs/tags/*:refs/tags/*' + if git rev-parse --verify refs/notes/hg >/dev/null 2>&1; then + git push origin refs/notes/hg:refs/notes/hg + fi