-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (140 loc) · 5.93 KB
/
deploy_github_pages.yml
File metadata and controls
161 lines (140 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# .github/workflows/deploy_github_pages.yml
#
# Builds the demo frontend (VITE_DEMO_MODE=true, Capital District GeoJSON data)
# and deploys it to GitHub Pages and Netlify.
#
# Triggers:
# - Push to main (any change under frontend/ or demo/) → roads + frontend only
# - Monthly schedule (1st of each month) → contacts rebuild; roads rebuilt quarterly
# - Manual dispatch → choose which pipelines to run
#
# Rebuild schedule (automated):
# - Contacts (PDF parse): every 1st of the month at 08:00 UTC
# - Roads (RIS GeoJSON): quarterly — March, June, September, December
#
# Manual dispatch inputs:
# - rebuild_contacts: re-download and parse NYSDOT + NYSCHSA contact PDFs
# - rebuild_roads: re-fetch Capital District road data from NYSDOT RIS
name: Deploy to GitHub Pages
on:
push:
branches: [main]
paths:
- "frontend/**"
- "demo/**"
- ".github/workflows/deploy_github_pages.yml"
schedule:
# Runs on the 1st of every month at 08:00 UTC.
# Roads are rebuilt only on quarterly months (logic inside the job).
- cron: "0 8 1 * *"
workflow_dispatch:
inputs:
rebuild_contacts:
description: "Rebuild contact data from NYSDOT + NYSCHSA PDFs"
type: boolean
default: true
rebuild_roads:
description: "Re-fetch road GeoJSON from NYSDOT RIS (slow — ~10 min)"
type: boolean
default: true
concurrency:
group: github-pages
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
name: Build demo frontend
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ── Node (for demo data build + Vite) ─────────────────────────────
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: |
frontend/package-lock.json
demo/package-lock.json
# ── Determine which pipelines to run ──────────────────────────────
# On push: rebuild roads only (contacts stay from last scheduled run)
# On schedule: rebuild contacts always; roads only on quarterly months
# On dispatch: honor user inputs
- name: Determine build flags
id: flags
run: |
MONTH=$(date +%-m)
EVENT="${{ github.event_name }}"
if [[ "$EVENT" == "push" ]]; then
echo "rebuild_contacts=false" >> $GITHUB_OUTPUT
echo "rebuild_roads=true" >> $GITHUB_OUTPUT
elif [[ "$EVENT" == "schedule" ]]; then
echo "rebuild_contacts=true" >> $GITHUB_OUTPUT
# Rebuild roads quarterly: March(3), June(6), September(9), December(12)
if [[ "$MONTH" =~ ^(3|6|9|12)$ ]]; then
echo "rebuild_roads=true" >> $GITHUB_OUTPUT
else
echo "rebuild_roads=false" >> $GITHUB_OUTPUT
fi
elif [[ "$EVENT" == "workflow_dispatch" ]]; then
echo "rebuild_contacts=${{ github.event.inputs.rebuild_contacts }}" >> $GITHUB_OUTPUT
echo "rebuild_roads=${{ github.event.inputs.rebuild_roads }}" >> $GITHUB_OUTPUT
else
# Safety fallback
echo "rebuild_contacts=false" >> $GITHUB_OUTPUT
echo "rebuild_roads=true" >> $GITHUB_OUTPUT
fi
# ── (Optional) Rebuild contact data from PDFs ──────────────────────
# Downloads NYSDOT Municipal Contacts PDF + NYSCHSA Directory,
# parses primary + backup contacts, writes contacts_lookup.json.
- name: Install demo pipeline dependencies
if: steps.flags.outputs.rebuild_contacts == 'true'
working-directory: demo
run: npm ci
- name: Rebuild contact data from PDFs
if: steps.flags.outputs.rebuild_contacts == 'true'
run: node demo/build_contacts.js
# ── (Optional) Generate road GeoJSON from NYSDOT RIS ───────────────
# This fetches from https://gis.dot.ny.gov — no secrets required.
- name: Generate demo GeoJSON data
if: steps.flags.outputs.rebuild_roads == 'true'
run: node demo/build_demo_geojson.js
# ── Install frontend deps ──────────────────────────────────────────
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
# ── Build ─────────────────────────────────────────────────────────
- name: Build
working-directory: frontend
env:
VITE_DEMO_MODE: "true"
# Subdirectory path for GitHub Pages project site.
# The trailing slash is required.
VITE_BASE_PATH: "/${{ github.event.repository.name }}/"
# Tiles/data are served from the same dist/ output.
# Leave VITE_TILES_BASE_URL blank → uses relative "./data" path.
VITE_REPORT_API_URL: ""
run: npm run build
# ── Configure Pages (adds .nojekyll so _assets/ directories work) ─
- name: Setup Pages
uses: actions/configure-pages@v5
# ── Upload dist/ as the Pages artifact ────────────────────────────
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: frontend/dist
deploy:
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4