This commit is contained in:
parent
2b450f0275
commit
da2c4e921f
1 changed files with 32 additions and 33 deletions
|
|
@ -11,40 +11,39 @@ jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Build Astro and restart Nomad
|
||||||
|
env:
|
||||||
- name: Set up Node.js
|
NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }}
|
||||||
uses: actions/setup-node@v4
|
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
|
||||||
with:
|
REPO_URL: https://git.bcgen.ie/familyfedie/familyfedie-website.git
|
||||||
node-version: 24
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Build Astro static site
|
|
||||||
run: |
|
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
|
rm -rf dist
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: Verify static output
|
|
||||||
run: |
|
|
||||||
test -f dist/index.html
|
test -f dist/index.html
|
||||||
test -f dist/speeches/index.html
|
test -f dist/speeches/index.html
|
||||||
test -f dist/assets/icons/familyfed-favicon.png
|
test -f dist/assets/icons/familyfed-favicon.png
|
||||||
|
|
||||||
- name: Restart Nomad allocation
|
|
||||||
env:
|
|
||||||
NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }}
|
|
||||||
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
ALLOC_ID=$(curl -sf \
|
ALLOC_ID=$(curl -sf \
|
||||||
-H "X-Nomad-Token: $NOMAD_TOKEN" \
|
-H "X-Nomad-Token: $NOMAD_TOKEN" \
|
||||||
"$NOMAD_ADDR/v1/job/familyfed/allocations" \
|
"$NOMAD_ADDR/v1/job/familyfed/allocations" \
|
||||||
| python3 -c "import sys,json; allocs=json.load(sys.stdin); print(next(a['ID'] for a in allocs if a['ClientStatus']=='running'))")
|
| 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"
|
echo "Stopping allocation to trigger fresh prestart: $ALLOC_ID"
|
||||||
curl -sf -X POST \
|
curl -sf -X POST \
|
||||||
-H "X-Nomad-Token: $NOMAD_TOKEN" \
|
-H "X-Nomad-Token: $NOMAD_TOKEN" \
|
||||||
"$NOMAD_ADDR/v1/allocation/$ALLOC_ID/stop"
|
"$NOMAD_ADDR/v1/allocation/$ALLOC_ID/stop"
|
||||||
echo "Deploy triggered — Nomad will schedule a new alloc that re-fetches the site."
|
echo "Deploy triggered. Nomad will schedule a new alloc that re-fetches the site."
|
||||||
|
'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue