diff --git a/.ngit/act/workflows/deploy-nsite.yml b/.ngit/act/workflows/deploy-nsite.yml new file mode 100644 index 00000000..b38c911c --- /dev/null +++ b/.ngit/act/workflows/deploy-nsite.yml @@ -0,0 +1,96 @@ +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___ (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. 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. + curl -sSL -o /usr/local/bin/nsyte \ + https://github.com/sandwichfarm/nsyte/releases/download/v0.27.2/nsyte-linux-0.27.2 + chmod +x /usr/local/bin/nsyte + + 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 diff --git a/.ngit/act/workflows/test.yml b/.ngit/act/workflows/test.yml new file mode 100644 index 00000000..59313880 --- /dev/null +++ b/.ngit/act/workflows/test.yml @@ -0,0 +1,31 @@ +name: Test + +# Typecheck / lint / unit tests / production build for the Shakespeare client. +# ngit-ci watches .ngit/act/workflows/ and runs each job with `act` (GitHub +# Actions-compatible syntax) in a Linux container. Runs on every push and on +# every Nostr PR. + +on: + push: + branches: ["**"] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + - run: npm ci + + # package.json splits these: "typecheck" is tsc --noEmit and "test" is + # eslint + vitest. The GitLab job ran typecheck, build and test; keep all + # three so a type error still fails CI. + - run: npm run typecheck + - run: npm run build + - run: npm run test diff --git a/.nsite/config.json b/.nsite/config.json new file mode 100644 index 00000000..a29cd1b8 --- /dev/null +++ b/.nsite/config.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://nsyte.run/schemas/config.schema.json", + "relays": [ + "wss://relay.ditto.pub", + "wss://relay.dreamith.to", + "wss://relay.primal.net" + ], + "id": "shakespeare", + "servers": [ + "https://blossom.ditto.pub", + "https://blossom.dreamith.to", + "https://blossom.primal.net" + ], + "fallback": "/index.html", + "publishRelayList": false, + "publishServerList": false, + "title": "Shakespeare", + "description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment.", + "source": "https://gitworkshop.dev/soapbox.pub/relay.ngit.dev/shakespeare" +}