familyfedie-website/.forgejo/workflows/deploy.yml
Loyyd da2c4e921f
Some checks failed
/ deploy (push) Failing after 1s
Run Forgejo deploy workflow on host runner
2026-06-11 16:39:17 +02:00

49 lines
1.6 KiB
YAML

on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: deploy-main
cancel-in-progress: true
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Build Astro and restart Nomad
env:
NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }}
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
REPO_URL: https://git.bcgen.ie/familyfedie/familyfedie-website.git
run: |
set -eu
rm -rf source
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
ALLOC_ID=$(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"
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."
'