Skip to content

Commit dd1f375

Browse files
authored
Merge pull request #632 from brownplt/add-monorepo-mirror-action
Add monorepo-mirror Action (subtree-split code.pyret.org from pyret-lang)
2 parents b9362de + 48ae651 commit dd1f375

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Mirror monorepo code.pyret.org subtree
2+
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.
7+
#
8+
# Runs in brownplt/code.pyret.org so it can push to a branch here with the
9+
# built-in GITHUB_TOKEN -- no PAT or deploy key needed. The monorepo is public,
10+
# so it's checked out read-only with that same token.
11+
#
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.
22+
23+
on:
24+
workflow_dispatch:
25+
inputs:
26+
source_ref:
27+
description: "Branch/ref of brownplt/pyret-lang to mirror"
28+
required: true
29+
default: drydock
30+
# schedule:
31+
# - cron: "0 7 * * *" # daily at 07:00 UTC
32+
33+
permissions:
34+
contents: write
35+
36+
concurrency:
37+
group: monorepo-mirror
38+
cancel-in-progress: false
39+
40+
jobs:
41+
mirror:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout monorepo (full history)
45+
uses: actions/checkout@v4
46+
with:
47+
repository: brownplt/pyret-lang
48+
ref: ${{ github.event.inputs.source_ref || 'drydock' }}
49+
fetch-depth: 0
50+
path: monorepo
51+
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/
59+
working-directory: monorepo
60+
run: |
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
76+
77+
- name: Push to monorepo-mirror branch of this repo
78+
working-directory: monorepo
79+
env:
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
run: |
82+
git push --force \
83+
"https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" \
84+
HEAD:monorepo-mirror
85+
echo "Pushed HEAD -> monorepo-mirror"

0 commit comments

Comments
 (0)