MCToolsHub is a small site with browser tools for Minecraft server owners: an MOTD editor, a server.properties generator, an SRV record helper and so on. It runs on a Cloudflare Worker from a private repo. The tools are the part people actually use, and I wanted them to be open so anyone could fix a bug or add a tool. The rest of the site (routing, guides, ads, SEO bits) I wanted to keep private.
This is how I split it up, and the one rule I set for the sync.
The layout
The public repo, mctoolshub-tools, holds nothing but the tools:
tools/ order.json # which tools exist, in what order motd-generator/ tool.json # title, description, how-to steps, FAQ panel.html # the markup for the tool itself ... assets/ style.css tools.js # all client-side logic scripts/ build.mjs # local preview, no dependencies Each tool is a folder with a JSON file and an HTML fragment. All the JavaScript lives in one file in assets/. There is no framework and no build step to get a tool working. node scripts/build.mjs writes static pages into site/ so a contributor can open them in a browser and test.
The private repo has the Worker. It used to have the tool data hardcoded in TypeScript. Now it imports it from a generated file:
import { TOOL_DATA, TOOL_STYLES, TOOL_SCRIPT, TOOLS_VERSION } from "./tools.generated"; The sync
A GitHub Action in the private repo checks out the public repo, turns it into src/tools.generated.ts, and commits the file if anything changed. Cloudflare Workers Builds deploys on every push to main, so the new tools go live after that.
on: schedule: - cron: "23 */6 * * *" workflow_dispatch: jobs: sync: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: TeXxZz/mctoolshub-tools path: _tools persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 - run: node scripts/sync-tools.mjs _tools - run: | if git diff --quiet -- src/tools.generated.ts; then exit 0; fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add src/tools.generated.ts git commit -m "Sync tools (mctoolshub-tools@$(git -C _tools rev-parse --short HEAD))" git push It runs every six hours and can be started by hand. The minute is 23 instead of 0 because a lot of scheduled workflows start on the hour and GitHub delays them.
The rule: never run code from the public repo
This is the part I thought about most. The Action runs with write access to the private repo. If it ran npm install or node scripts/build.mjs from the public repo, anyone who got a pull request merged could run code with that token.
So the sync script only reads files as text. It never imports, requires or executes anything from _tools:
const read = (...p) => fs.readFileSync(path.join(SRC, ...p), "utf8"); const tools = order.map((slug) => { if (!/^[a-z0-9-]+$/.test(slug)) fail(`bad tool name: ${slug}`); const meta = JSON.parse(read("tools", slug, "tool.json")); const body = read("tools", slug, "panel.html").trim(); if (/<script\b/i.test(body)) fail(`${slug}/panel.html has a <script> tag`); // ...check required fields, then return plain data }); A few checks keep bad data out:
- Tool names have to match
^[a-z0-9-]+$, so nobody can use../to read files outside the tools folder. -
tool.jsonhas to have every required field, and FAQ entries have to be pairs. -
panel.htmlcannot have a<script>tag. All logic goes intools.js, which is one file and easy to review.
If any check fails, the script exits with an error and nothing gets committed. The site keeps running the last good version.
Of course tools.js still ends up on the live site, so a merged pull request can change what runs in visitors' browsers. That is true for any open-source frontend. The protection there is reviewing pull requests, which is easier when all the JavaScript is in one file. What the rule protects is the private repo and its secrets.
Cache busting from content
The Worker serves the CSS and JS with cache headers, so the file names need to change when the content changes. Otherwise visitors get new HTML with an old tools.js. The sync script hashes everything it writes:
const version = crypto.createHash("sha256") .update(JSON.stringify(tools) + styles + script) .digest("hex").slice(0, 10); The Worker puts that in the file name (/assets/tools.<version>.js). If a sync changes nothing, the hash is the same and browsers keep their cache. If one character in a tool changes, every page gets the new files.
Checking nothing broke
Before switching over, I rendered every route of the old Worker and the new one to HTML and diffed them. All 51 pages were identical apart from the asset version string. That gave me enough confidence to ship it without clicking through everything by hand.
Was it worth it?
The tools are now easy to contribute to without access to the site, and the private repo stays private. If you have a site where one part is useful to others, this pattern is simple to copy: keep the shared part as plain data, sync it as text, and validate it before it lands.
The tools are live on the Minecraft server tools page if you want to see the result, for example the MOTD generator or the server.properties generator. Issues and pull requests on the repo are welcome.

