11name : Mirror monorepo code.pyret.org subtree
22
3- # Generates a flat, deployable mirror of the code.pyret.org/ subfolder of the
4- # brownplt/pyret-lang monorepo, with history preserved, on the
5- # `monorepo-mirror` branch of THIS repo.
3+ # Generates a deployable, history-preserving mirror of the code.pyret.org/
4+ # subfolder of the brownplt/pyret-lang monorepo on the `monorepo-mirror` branch
5+ # of THIS repo, so downstream forks (e.g. Bootstrap/PBO) can keep their
6+ # pull -> push -> Heroku "Deploy" workflow once CPO lives in the monorepo.
67#
7- # Runs in brownplt/code.pyret.org so it can push to a branch here using the
8+ # Runs in brownplt/code.pyret.org so it can push to a branch here with the
89# built-in GITHUB_TOKEN -- no PAT or deploy key needed. The monorepo is public,
9- # so it is checked out read-only with that same token.
10+ # so it's checked out read-only with that same token.
1011#
11- # Manual-only for now: trigger from the Actions tab and pick the source ref.
12- # Uncomment the `schedule` block below to run it automatically once this is
13- # trusted.
12+ # Extraction uses `git filter-repo` (sub-second). `git subtree split` produces
13+ # the same result but re-walks all ~12k monorepo commits and takes ~an hour, so
14+ # it's not viable here. The mirror is the history of code.pyret.org/ rewritten to
15+ # the repo root, plus one commit that copies the shared ../codemirror-mode
16+ # sibling in as a real `mode/` directory: CPO's Makefile reads the CodeMirror
17+ # mode from a local `mode/` (a gitignored symlink in the monorepo), so the slice
18+ # must ship it as a real dir for `make web` to build standalone on Heroku. (The
19+ # brand images the build needs are already vendored into src/web/img.)
20+ #
21+ # Manual-only for now; uncomment `schedule` to run automatically once trusted.
1422
1523on :
1624 workflow_dispatch :
1725 inputs :
1826 source_ref :
1927 description : " Branch/ref of brownplt/pyret-lang to mirror"
2028 required : true
21- default : mainmast
29+ default : drydock
2230 # schedule:
2331 # - cron: "0 7 * * *" # daily at 07:00 UTC
2432
@@ -37,16 +45,34 @@ jobs:
3745 uses : actions/checkout@v4
3846 with :
3947 repository : brownplt/pyret-lang
40- ref : ${{ github.event.inputs.source_ref || 'mainmast ' }}
48+ ref : ${{ github.event.inputs.source_ref || 'drydock ' }}
4149 fetch-depth : 0
4250 path : monorepo
4351
44- - name : Split code.pyret.org subtree (preserves history)
52+ - name : Install git-filter-repo
53+ run : |
54+ sudo apt-get update -qq
55+ sudo apt-get install -y git-filter-repo
56+ git filter-repo --version
57+
58+ - name : Extract code.pyret.org (history-preserving) + materialize mode/
4559 working-directory : monorepo
4660 run : |
47- git subtree split --prefix=code.pyret.org -b mirror-split
48- echo "Split tip: $(git rev-parse mirror-split)"
49- git log --oneline -5 mirror-split
61+ set -euo pipefail
62+ # Stash the shared codemirror-mode sibling before filter-repo prunes it.
63+ cp -r codemirror-mode /tmp/codemirror-mode
64+ # Rewrite history so code.pyret.org/ becomes the repo root.
65+ git filter-repo --subdirectory-filter code.pyret.org --force
66+ # CPO reads the CodeMirror mode from a local `mode/` (a gitignored
67+ # symlink in the monorepo). Ship a real copy so a downstream Heroku
68+ # build of this mirror is self-contained.
69+ rm -rf mode
70+ cp -r /tmp/codemirror-mode mode
71+ git config user.name "pyret-mirror bot"
72+ git config user.email "119891+jpolitz@users.noreply.github.com"
73+ git add -f mode
74+ git commit -m "Materialize codemirror-mode for standalone deploy"
75+ git log --oneline -5
5076
5177 - name : Push to monorepo-mirror branch of this repo
5278 working-directory : monorepo
5581 run : |
5682 git push --force \
5783 "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" \
58- mirror-split :monorepo-mirror
59- echo "Pushed mirror-split -> monorepo-mirror"
84+ HEAD :monorepo-mirror
85+ echo "Pushed HEAD -> monorepo-mirror"
0 commit comments