~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zat

atproto utils for zig · mirror of https://tangled.org/zat.dev/zat

0
0
66 lines · 2.3 KB Raw History
# only pushes that change the site or what it is built from deploy it.
when:
  - event: ["push"]
    branch: main
    paths: ["site/**", "docs/**", "devlog/**", README.md, CHANGELOG.md, scripts/build-site.mjs, scripts/site-route.test.mjs, scripts/ci-node.sh, scripts/ci-docs-tls.mjs, .tangled/workflows/deploy-website.yml]

engine: nixery

dependencies:
  nixpkgs:
    - bun
    - coreutils
    - curl
    - gnutar
    - gcc
    - patchelf
    - xz

environment:
  WISP_HANDLE: "zat.dev"
  WISP_SITE_NAME: "docs"

steps:
  - name: test site routing
    command: |
      bun test ./scripts

  - name: build site
    command: |
      bun ./scripts/build-site.mjs

  - name: install verified publishing tools
    command: |
      set -eu
      env -u ATPROTO_PASSWORD -u WISPCTL_APP_PASSWORD scripts/ci-node.sh
      export PATH="$PWD/.ci-tools/node/bin:$PATH"
      env -u ATPROTO_PASSWORD -u WISPCTL_APP_PASSWORD node scripts/ci-docs-tls.mjs
      env -u ATPROTO_PASSWORD -u WISPCTL_APP_PASSWORD node .ci-tools/node/lib/node_modules/npm/bin/npm-cli.js install --prefix .ci-tools/wisp --ignore-scripts --no-audit --no-fund --save-exact wispctl@2.1.2
      test "$(env -u ATPROTO_PASSWORD -u WISPCTL_APP_PASSWORD node .ci-tools/wisp/node_modules/wispctl/bin/wispctl.js --version)" = 2.1.2

  - name: deploy docs to wisp
    command: |
      export PATH="$PWD/.ci-tools/node/bin:$PATH"
      if [ -z "$ATPROTO_PASSWORD" ]; then
        echo "ATPROTO_PASSWORD is not set; cannot deploy docs" >&2
        exit 1
      fi
      # pds.zat.dev can transiently return InternalServerError while creating a
      # session. Retry the idempotent/incremental deploy before failing the job.
      rc=1
      for attempt in 1 2 3 4 5; do
        WISPCTL_APP_PASSWORD="$ATPROTO_PASSWORD" node .ci-tools/wisp/node_modules/wispctl/bin/wispctl.js deploy "$WISP_HANDLE" --path ./site-out --site "$WISP_SITE_NAME" --yes
        rc=$?
        if [ "$rc" -eq 0 ]; then
          break
        fi
        if [ "$attempt" -lt 5 ]; then
          delay=$((attempt * 10))
          echo "wisp docs deploy attempt $attempt failed; retrying in ${delay}s" >&2
          sleep "$delay"
        fi
      done
      if [ "$rc" -ne 0 ]; then
        echo "wisp docs deploy failed after 5 attempts (wisp-cli exit $rc)" >&2
        exit "$rc"
      fi