diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 106267eb..3d38dca4 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -69,27 +69,27 @@ jobs: test -f dist/speeches/index.html test -f dist/assets/icons/familyfed-favicon.png - ALLOC_ID=$( - curl -fsS \ - --connect-timeout 15 \ - --max-time 60 \ - --retry 3 \ - --retry-delay 5 \ - --retry-all-errors \ - -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" - curl -fsS -X POST \ + export DEPLOY_COMMIT="${GITHUB_SHA:-$(git rev-parse HEAD)}" + echo "Registering Nomad deployment for $DEPLOY_COMMIT" + curl -fsS \ --connect-timeout 15 \ --max-time 60 \ --retry 3 \ --retry-delay 5 \ --retry-all-errors \ -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." + "$NOMAD_ADDR/v1/job/familyfed" \ + | jq '(.TaskGroups[].Tasks[].Env //= {}) | .TaskGroups[].Tasks[].Env.DEPLOY_COMMIT = env.DEPLOY_COMMIT | {Job: .}' \ + > /tmp/familyfed-job.json + + curl -fsS -X POST \ + --connect-timeout 15 \ + --max-time 60 \ + --retry 3 \ + --retry-delay 5 \ + --retry-all-errors \ + -H "Content-Type: application/json" \ + -H "X-Nomad-Token: $NOMAD_TOKEN" \ + --data-binary @/tmp/familyfed-job.json \ + "$NOMAD_ADDR/v1/jobs" + echo "Deploy registered. Nomad will replace the allocation and re-fetch the site."