| 1 | #!/usr/bin/env sh |
| 2 | # Step 1 of publishing the guide to elevenmessenger.com — mirrors |
| 3 | # docs/planet-scale-guide/ into elevenmessenger/website's src/infrastructure/ |
| 4 | # (Eleventy passthrough-copies it to /infrastructure/ unmodified — see that |
| 5 | # repo's .eleventy.js), commits, and pushes the website's main. |
| 6 | # |
| 7 | # The old GitHub Actions auto-sync (.github/workflows/sync-guide-to-website.yml) |
| 8 | # is DISABLED — the project builds the site locally now — so this is the normal |
| 9 | # path, not a fallback. After it pushes, run ./deploy.sh in the website checkout |
| 10 | # to build and publish (step 2). It needs no token: it uses your own local git |
| 11 | # credentials, exactly like pushing any other change by hand. |
| 12 | # |
| 13 | # ./tools/sync-guide-to-website.sh <path-to-a-local-checkout-of-website> |
| 14 | # |
| 15 | # # first time: clone it somewhere, then point this script at it |
| 16 | # gh repo clone elevenmessenger/website /tmp/website |
| 17 | # ./tools/sync-guide-to-website.sh /tmp/website |
| 18 | set -eu |
| 19 | |
| 20 | WEBSITE_DIR="${1:?usage: $0 <path-to-a-local-checkout-of-elevenmessenger/website>}" |
| 21 | REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| 22 | |
| 23 | if [ ! -d "$WEBSITE_DIR/.git" ]; then |
| 24 | echo "sync-guide-to-website: $WEBSITE_DIR is not a git checkout — clone elevenmessenger/website there first" >&2 |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | echo "Updating $WEBSITE_DIR (git pull)..." |
| 29 | git -C "$WEBSITE_DIR" pull --ff-only |
| 30 | |
| 31 | echo "Copying $REPO_ROOT/docs/planet-scale-guide/ -> $WEBSITE_DIR/src/infrastructure/..." |
| 32 | rm -rf "$WEBSITE_DIR/src/infrastructure" |
| 33 | mkdir -p "$WEBSITE_DIR/src/infrastructure" |
| 34 | cp -r "$REPO_ROOT"/docs/planet-scale-guide/* "$WEBSITE_DIR/src/infrastructure/" |
| 35 | |
| 36 | cd "$WEBSITE_DIR" |
| 37 | git add src/infrastructure |
| 38 | if git diff --cached --quiet; then |
| 39 | echo "No changes to the guide — nothing to sync." |
| 40 | exit 0 |
| 41 | fi |
| 42 | git commit -m "docs: sync planet-scale guide from elevenmessenger/messenger@$(git -C "$REPO_ROOT" rev-parse --short HEAD)" |
| 43 | git push |
| 44 | echo "Pushed website main. Now run ./deploy.sh in $WEBSITE_DIR to build + publish (no Actions)." |
| 45 | |