the static git browser that builds this site
git clone https://git.lucas.co/gitsite.git
deploy.sh (1.4K)
1 #!/bin/sh
2 # Deploy the built site to Cloudflare Pages.
3 # One-time setup: npx wrangler login
4 set -e
5
6 OUT="$HOME/.cache/gitsite/out"
7 [ -d "$OUT" ] || { echo "no build output; run ./build.sh first" >&2; exit 1; }
8
9 # Token auth when available: wrangler refuses OAuth in non-interactive
10 # environments (e.g. the gitsite.timer systemd unit).
11 #
12 # Credentials and account identifiers live outside the repo, mode 600, the
13 # way restic-backup.sh keeps its own. They used to be here: the token was
14 # already read from a file, but the account id was inline -- fine while this
15 # repo was private, less so now that gitsite publishes itself to
16 # git.lucas.co. Nothing secret belongs in this file.
17 ENV_FILE="${GITSITE_ENV_FILE:-$HOME/.config/gitsite/env}"
18 TOKEN_FILE="$HOME/.config/gitsite-cf-token" # older layout, token only
19
20 if [ -f "$ENV_FILE" ]; then
21 . "$ENV_FILE"
22 export CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID
23 elif [ -f "$TOKEN_FILE" ]; then
24 # A machine that has not been migrated yet. Without an account id wrangler
25 # falls back to the one in its own cache, which is how this used to work.
26 CLOUDFLARE_API_TOKEN=$(tr -d '[:space:]' < "$TOKEN_FILE")
27 export CLOUDFLARE_API_TOKEN
28 fi
29
30 # Pinned: wrangler 4.121.0 ships a dependency on a nonexistent miniflare
31 # alpha (npm ETARGET); bump when upstream fixes their release.
32 npx -y [email protected] pages deploy "$OUT" --project-name=git-lucas-co --branch=main --commit-dirty=true