diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 7de05240..787303ae 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -22,28 +22,32 @@ jobs: export REF_NAME="${GITHUB_REF_NAME:-main}" nix --extra-experimental-features "nix-command flakes" \ - shell nixpkgs#git nixpkgs#nodejs_24 nixpkgs#curl nixpkgs#jq \ - -c sh -lc ' - set -eu - git clone --depth 1 --branch "$REF_NAME" "$REPO_URL" source - cd source - npm ci - rm -rf dist - npm run build - test -f dist/index.html - test -f dist/speeches/index.html - test -f dist/assets/icons/familyfed-favicon.png + shell nixpkgs#git \ + -c git clone --depth 1 --branch "$REF_NAME" "$REPO_URL" source - ALLOC_ID=$(curl -sf \ - -H "X-Nomad-Token: $NOMAD_TOKEN" \ - "$NOMAD_ADDR/v1/job/familyfed/allocations" \ - | jq -r "map(select(.ClientStatus == \"running\"))[0].ID") + cd source + nix --extra-experimental-features "nix-command flakes" \ + shell nixpkgs#nodejs_24 \ + -c npm ci + rm -rf dist + nix --extra-experimental-features "nix-command flakes" \ + shell nixpkgs#nodejs_24 \ + -c npm run build - test -n "$ALLOC_ID" - test "$ALLOC_ID" != "null" - echo "Stopping allocation to trigger fresh prestart: $ALLOC_ID" - curl -sf -X POST \ - -H "X-Nomad-Token: $NOMAD_TOKEN" \ - "$NOMAD_ADDR/v1/allocation/$ALLOC_ID/stop" - echo "Deploy triggered. Nomad will schedule a new alloc that re-fetches the site." - ' + test -f dist/index.html + test -f dist/speeches/index.html + test -f dist/assets/icons/familyfed-favicon.png + + ALLOC_ID=$(nix --extra-experimental-features "nix-command flakes" \ + shell nixpkgs#curl nixpkgs#jq \ + -c sh -c 'curl -sf -H "X-Nomad-Token: $NOMAD_TOKEN" "$NOMAD_ADDR/v1/job/familyfed/allocations" | jq -r "map(select(.ClientStatus == \"running\"))[0].ID"') + + test -n "$ALLOC_ID" + test "$ALLOC_ID" != "null" + echo "Stopping allocation to trigger fresh prestart: $ALLOC_ID" + nix --extra-experimental-features "nix-command flakes" \ + shell nixpkgs#curl \ + -c curl -sf -X POST \ + -H "X-Nomad-Token: $NOMAD_TOKEN" \ + "$NOMAD_ADDR/v1/allocation/$ALLOC_ID/stop" + echo "Deploy triggered. Nomad will schedule a new alloc that re-fetches the site."