on: push: branches: [main] workflow_dispatch: concurrency: group: deploy-main cancel-in-progress: true jobs: deploy: runs-on: docker container: image: node:24-bookworm timeout-minutes: 30 steps: - name: Install deploy tools run: | set -eu apt-get update -qq apt-get install -y -q ca-certificates curl git jq - name: Build Astro and restart Nomad env: NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }} NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }} PUBLIC_ANALYTICS_DASHBOARD_URL: ${{ secrets.PUBLIC_ANALYTICS_DASHBOARD_URL }} PUBLIC_CONTACT_FORM_ENDPOINT: ${{ secrets.PUBLIC_CONTACT_FORM_ENDPOINT }} PUBLIC_CONTACT_RECIPIENTS: ${{ secrets.PUBLIC_CONTACT_RECIPIENTS }} PUBLIC_CONTACT_SUBMISSIONS_URL: ${{ secrets.PUBLIC_CONTACT_SUBMISSIONS_URL }} PUBLIC_PLAUSIBLE_DOMAIN: ${{ secrets.PUBLIC_PLAUSIBLE_DOMAIN }} PUBLIC_PLAUSIBLE_SCRIPT_SRC: ${{ secrets.PUBLIC_PLAUSIBLE_SCRIPT_SRC }} REPO_URL: https://git.bcgen.ie/familyfedie/familyfedie-website.git run: | set -eu export REF_NAME="${GITHUB_REF_NAME:-main}" git config --global http.lowSpeedLimit 1024 git config --global http.lowSpeedTime 60 for attempt in 1 2 3; do echo "Cloning $REPO_URL ($REF_NAME), attempt $attempt/3" rm -rf source if timeout 180 git clone --depth 1 --branch "$REF_NAME" "$REPO_URL" source; then break fi if [ "$attempt" -eq 3 ]; then echo "git clone failed after 3 attempts" >&2 exit 1 fi sleep $((attempt * 10)) done cd source npm ci --no-audit --no-fund rm -rf dist npm run build test -f dist/index.html test -f dist/admin/index.html 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 \ --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."