Something went wrong. Try again.
Central platform for European atproto.<cc> country community websites atproto.eu
community atproto
Something went wrong. Try again.
Shell
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#!/usr/bin/env bash# Publish a built static site to Codeberg Pages.## One codebase, three real domains (atproto.nl/.be/.eu). SITE_SCOPE picks which one this run# builds and which Codeberg repo it pushes to; each domain is a standalone Codeberg Pages repo# with its own `pages` branch. Home base stays Tangled; Codeberg is only the delivery layer.## The custom domain is claimed by dist/.domains, which astro.config.mjs writes from the scope at# build time -- so this script never has to know the hostname, only which remote to push.## Usage:# SITE_SCOPE=nl bash scripts/deploy-codeberg.sh # -> remote `codeberg` (atproto.nl)# SITE_SCOPE=be bash scripts/deploy-codeberg.sh # -> remote `codeberg-be` (atproto.be)# SITE_SCOPE=eu bash scripts/deploy-codeberg.sh # -> remote `codeberg-eu` (atproto.eu)# Deploy all three: for s in nl be eu; do SITE_SCOPE=$s bash scripts/deploy-codeberg.sh; done## Prereqs (per scope): a Codeberg remote over ssh (auth via ~/.ssh/id_ed25519_codeberg), e.g.# git remote add codeberg-be codeberg.org:gxjansen/atprotobe-website.git# git remote add codeberg-eu codeberg.org:gxjansen/atprotoeu-website.git# and rsync available. The `_git-pages-repository.<domain>` TXT record must point at the same repo.set -euo pipefail
SCOPE="${SITE_SCOPE:-nl}"case "$SCOPE" in nl) DEFAULT_REMOTE="codeberg" ;; be) DEFAULT_REMOTE="codeberg-be" ;; no) DEFAULT_REMOTE="codeberg-no" ;; hu) DEFAULT_REMOTE="codeberg-hu" ;; eu) DEFAULT_REMOTE="codeberg-eu" ;; *) echo "Unknown SITE_SCOPE='$SCOPE' (want nl|be|no|hu|eu)" >&2; exit 1 ;;esac
# CODEBERG_REMOTE still overrides for one-off targets (e.g. a preview repo).REMOTE="${CODEBERG_REMOTE:-$DEFAULT_REMOTE}"BRANCH="${CODEBERG_PAGES_BRANCH:-pages}"export SITE_SCOPE="$SCOPE"
if ! git remote get-url "$REMOTE" >/dev/null 2>&1; then echo "Git remote '$REMOTE' not found. Add it, e.g.:" >&2 echo " git remote add $REMOTE codeberg.org:gxjansen/atproto${SCOPE}-website.git" >&2 exit 1fi
# Default base '/' — serve at the apex domain. For the codeberg.page/<repo>/ preview subpath:# SITE_BASE=/atproto${SCOPE}-website/ SITE_SCOPE=$SCOPE bash scripts/deploy-codeberg.shexport SITE_BASE="${SITE_BASE:-/}"
echo "==> Building scope=$SCOPE (base=$SITE_BASE) -> remote $REMOTE"npm run build
WT="$(mktemp -d)"cleanup() { git worktree remove --force "$WT" 2>/dev/null || true; }trap cleanup EXIT
echo "==> Preparing $REMOTE/$BRANCH worktree"git fetch "$REMOTE" "$BRANCH" 2>/dev/null || trueif git show-ref --verify --quiet "refs/remotes/$REMOTE/$BRANCH"; then git worktree add -B "$BRANCH" "$WT" "$REMOTE/$BRANCH"else git worktree add -B "$BRANCH" "$WT"fi
echo "==> Syncing dist/ -> $REMOTE/$BRANCH"rsync -a --delete --exclude='.git' dist/ "$WT/"git -C "$WT" add -Aif git -C "$WT" diff --cached --quiet; then echo "No changes to deploy." exit 0figit -C "$WT" commit -m "deploy $SCOPE $(git rev-parse --short HEAD)"git -C "$WT" push "$REMOTE" "$BRANCH"echo "==> Deployed scope=$SCOPE to Codeberg Pages ($REMOTE/$BRANCH)."