mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
The runner image turned out to carry no nsyte at all, so every deploy took the download fallback and ran 0.27.2, whose nostr-tools refuses to NIP-44 encrypt a payload over 64 KiB. Signing a site manifest through the bunker fails outright there. 0.28.0 is the first release with the fix, and it is now baked into the image. `command -v nsyte` also left the pin unenforceable: a baked binary of any vintage won silently, which is how deploys kept running 0.27.2 long after the pin moved. The check now compares versions and treats the pin as a floor, so a newer image still wins but an older one is replaced.
138 lines
6.2 KiB
YAML
138 lines
6.2 KiB
YAML
name: Deploy nsite
|
|
|
|
# Builds dist/ and publishes it as the named nsite "shakespeare" (NIP-5A kind
|
|
# 35128) described by .nsite/config.json: the files become Blossom blobs, the
|
|
# manifest mapping path -> sha256 goes to relays, and npanel on venus serves
|
|
# shakespeare.diy from it. Runs on pushes to the default branch, alongside
|
|
# Test.
|
|
#
|
|
# Replaces the GitLab `deploy-nsite` job, which published the same site under a
|
|
# PERSONAL npub with nsyte 0.24.1. The signing pubkey IS the site address, so
|
|
# this one lives in the Team Soapbox namespace instead.
|
|
#
|
|
# Secrets are provisioned by the ngit-ci operator as
|
|
# NGIT_CI_SECRET_<ALIAS>__<NAME> (note the double underscore) and injected ONLY
|
|
# on maintainer-authored triggers, which a push to a watched repo always is.
|
|
# This job needs one:
|
|
# NSYTE_BUNKER nbunksec1... -- a pre-established NIP-46 session, the form
|
|
# nsyte documents for CI.
|
|
# An empty NSYTE_BUNKER fails the job rather than skipping quietly: this is the
|
|
# only workflow that publishes the client anywhere, so a skipped run would
|
|
# leave the nsite silently pinned to an older build.
|
|
#
|
|
# NOTE: *.shakespeare.diy is NOT served from here. The wildcard keeps its own
|
|
# Caddy vhost and /var/www tree on venus, because the nsite catch-all issues
|
|
# certificates on demand over HTTP-01 and cannot get a wildcard.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
# Ahead of the build, so a config nsyte will not accept costs seconds
|
|
# rather than failing at the end of a green-looking run.
|
|
- name: Install nsyte and validate the config
|
|
env:
|
|
NSYTE_BUNKER: ${{ secrets.NSYTE_BUNKER }}
|
|
run: |
|
|
set -eu
|
|
: "${NSYTE_BUNKER:?NSYTE_BUNKER is not set; ask the ngit-ci operator to provision it for this repo alias.}"
|
|
|
|
# Pin the binary as a FLOOR, not an exact version. An unversioned
|
|
# install has been observed pulling 0.10.1, which emits legacy
|
|
# kind-34128 events that every current gateway ignores while still
|
|
# reporting a successful deploy. 0.28.0 is the floor because it is the
|
|
# first release whose nostr-tools will encrypt a NIP-44 payload larger
|
|
# than 64 KiB; under it, signing a large site manifest through the
|
|
# bunker fails outright.
|
|
#
|
|
# nsyte is baked into the coordinator's CI image alongside zsp
|
|
# (armada's .ngit/ci-image/Dockerfile). Comparing its VERSION rather
|
|
# than just `command -v` is deliberate: a stale baked binary silently
|
|
# outranked this pin, which is how deploys kept running 0.27.2 long
|
|
# after the pin moved. Accepting anything NEWER than the floor lets
|
|
# the image move ahead of these files without sending every job back
|
|
# to the download.
|
|
#
|
|
# That download is the fallback for a coordinator whose image lacks
|
|
# nsyte, and is exactly what kept failing here: the ~129 MB release
|
|
# asset broke mid-transfer with "SSL_read: decryption failed or bad
|
|
# record mac", identically on every attempt within a run, taking
|
|
# deploy-nsite down across every repo. Hence the loop, HTTP/1.1, and
|
|
# running the binary before trusting it.
|
|
NSYTE_MIN_VERSION=0.28.0
|
|
# nsyte colours its version output with ANSI escapes even when piped.
|
|
baked="$(NO_COLOR=1 nsyte --version 2>/dev/null \
|
|
| sed 's/\x1b\[[0-9;]*m//g' | awk 'NR == 1 { print $2 }')"
|
|
oldest="$(printf '%s\n%s\n' "$NSYTE_MIN_VERSION" "$baked" | sort -V | head -1)"
|
|
if [ -n "$baked" ] && [ "$oldest" = "$NSYTE_MIN_VERSION" ]; then
|
|
echo "using the nsyte baked into the runner image ($baked)"
|
|
else
|
|
test -z "$baked" || echo "baked nsyte $baked is below $NSYTE_MIN_VERSION; downloading"
|
|
NSYTE_URL="https://github.com/sandwichfarm/nsyte/releases/download/v${NSYTE_MIN_VERSION}/nsyte-linux-${NSYTE_MIN_VERSION}"
|
|
ok=""
|
|
for attempt in 1 2 3 4 5; do
|
|
if curl -fsSL --http1.1 --retry 2 --retry-delay 5 --retry-all-errors \
|
|
--connect-timeout 20 --max-time 900 -o /usr/local/bin/nsyte "$NSYTE_URL" \
|
|
&& chmod +x /usr/local/bin/nsyte \
|
|
&& nsyte --version >/dev/null; then
|
|
ok=yes
|
|
break
|
|
fi
|
|
echo "nsyte download attempt $attempt failed; retrying in 10s"
|
|
sleep 10
|
|
done
|
|
test -n "$ok" || { echo "could not download a working nsyte after 5 attempts"; exit 1; }
|
|
fi
|
|
nsyte --version
|
|
|
|
nsyte validate
|
|
|
|
- run: npm ci
|
|
|
|
# Builds dist/ and copies index.html -> 404.html, the path NIP-5A host
|
|
# servers fall back to.
|
|
- run: npm run build
|
|
|
|
# Sourcemaps are ~290 files and 30 MB of blobs nobody fetches, and they
|
|
# near-double the manifest. The GitLab job dropped them too.
|
|
- run: find dist -name '*.map' -delete
|
|
|
|
- name: Publish to Blossom + relays
|
|
env:
|
|
NSYTE_BUNKER: ${{ secrets.NSYTE_BUNKER }}
|
|
run: |
|
|
set -eu
|
|
|
|
# Relays, servers and the site id all come from .nsite/config.json,
|
|
# so they are versioned with the client rather than split across this
|
|
# file. The secrets scan is skipped because it prompts on false
|
|
# positives in our own bundle (pubkeys, bunker:// parsing code), and
|
|
# a prompt is unanswerable here -- with -i it defaults to N and
|
|
# aborts.
|
|
set +e
|
|
nsyte deploy dist \
|
|
--sec "$NSYTE_BUNKER" \
|
|
--concurrency 2 \
|
|
--non-interactive \
|
|
--skip-secrets-scan 2>&1 | tee /tmp/nsyte-deploy.log
|
|
status="${PIPESTATUS[0]}"
|
|
set -e
|
|
|
|
# A deploy that changes no file exits NON-ZERO with "No new files to
|
|
# upload". That is success: the manifest already on the relays
|
|
# describes exactly this build.
|
|
if [ "$status" -ne 0 ] && ! grep -q "No new files to upload" /tmp/nsyte-deploy.log; then
|
|
exit "$status"
|
|
fi
|