Repository navigation
172 lines (151 loc) · 6.66 KB
/
Copy pathdeploy.yml
File metadata and controls
172 lines (151 loc) · 6.66 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
162
163
164
165
166
167
168
169
170
171
172
name: Deploy
# Runs on every push, and on a schedule so the published flight-position
# snapshot stays reasonably current.
#
# GitHub's scheduled runs are best effort and are often delayed under load, so
# the app treats the snapshot as data that may be stale and labels it with its
# own timestamp rather than assuming it is fresh.
on:
push:
branches: [main]
schedule:
- cron: '*/15 * * * *'
- cron: '7,27,47 * * * *'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
# Reported routes: the Virtual Radar Server standing data (CC0), about
# 26 MB of CSV. Cloned at most once a day and cached between the
# quarter-hourly runs; if a clone fails, yesterday's copy is kept.
- name: Date for the route data cache
id: day
run: echo "day=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
id: standing-data
with:
path: .cache/standing-data
key: standing-data-${{ steps.day.outputs.day }}
restore-keys: standing-data-
- name: Refresh route data
if: steps.standing-data.outputs.cache-hit != 'true'
continue-on-error: true
run: |
rm -rf .cache/standing-data.new
git clone --quiet --depth 1 --filter=blob:none --sparse \
https://github.com/vradarserver/standing-data.git .cache/standing-data.new
git -C .cache/standing-data.new sparse-checkout set routes/schema-01 airports/schema-01
rm -rf .cache/standing-data
mv .cache/standing-data.new .cache/standing-data
# SetoffIQ's own record of arrivals. The published copy on the site is
# the main one; this cache is a second, so one failed fetch of the live
# file cannot reset two weeks of history. A new key every run, restored
# from the most recent.
- uses: actions/cache@v4
with:
path: |
.cache/history
.cache/schedule
key: arrival-history-${{ github.run_id }}
restore-keys: arrival-history-
# Aircraft near the airport from adsb.lol (ODbL 1.0), keyless. If it
# fails the committed snapshot is used instead, so a bad run never
# publishes an empty one — and the app will not place aircraft from a
# snapshot more than an hour old.
- name: Refresh flight position snapshot
continue-on-error: true
env:
STANDING_DATA_DIR: .cache/standing-data
HISTORY_CACHE_FILE: .cache/history/EGCC-history.json
APPROACH_CACHE_FILE: .cache/history/EGCC-approach.json
run: node scripts/fetch-flight-snapshot.mjs
# Manchester's schedule from AirLabs, keyed. The key is a repository
# secret used only here; without it nothing is published and the app
# falls back to live positions and its own record. Refreshed at most
# every 4.5 hours and within a monthly budget under the free plan's
# 1,000 requests — see scripts/fetch-schedule.mjs.
- name: Refresh flight schedule
continue-on-error: true
env:
AIRLABS_KEY: ${{ secrets.AIRLABS_KEY }}
STANDING_DATA_DIR: .cache/standing-data
SCHEDULE_CACHE_FILE: .cache/schedule/EGCC-schedule.json
LANDINGS_CACHE_FILE: .cache/schedule/EGCC-landings.json
run: node scripts/fetch-schedule.mjs
# Manchester's weekly timetable from AirLabs, keyed, refreshed monthly.
# A free key sees only about three hours of the schedule either side of
# now, so without this the picker is empty at night and useless to
# anyone planning a pickup tomorrow. It is fetched one airport pair at a
# time because a free key returns 50 rows per query and ignores offset —
# see scripts/fetch-timetable.mjs.
- name: Refresh flight timetable
continue-on-error: true
env:
AIRLABS_KEY: ${{ secrets.AIRLABS_KEY }}
STANDING_DATA_DIR: .cache/standing-data
TIMETABLE_CACHE_FILE: .cache/schedule/EGCC-timetable.json
run: node scripts/fetch-timetable.mjs
# Aerodrome observation. Free and keyless, but the Aviation Weather
# Center sends no CORS header, so it is fetched here rather than in the
# browser — the same pattern as the flight snapshot.
- name: Refresh airport conditions snapshot
continue-on-error: true
run: node scripts/fetch-airport-conditions.mjs
# Road disruption. Every free UK source for this requires a registered
# key, which is fine as long as the key stays here: it is read from a
# repository secret, used in CI, and never reaches a browser. No visitor
# is ever asked for a key or charged anything.
#
# With no secret set the script exits cleanly without writing a file, and
# the app reports road disruption as "not checked" — so a fork without
# the key is no worse off than the product was before it had one.
- name: Refresh road disruption snapshot
continue-on-error: true
env:
NATIONAL_HIGHWAYS_KEY: ${{ secrets.NATIONAL_HIGHWAYS_KEY }}
ROAD_DISRUPTION_URL: ${{ vars.ROAD_DISRUPTION_URL }}
run: node scripts/fetch-road-disruption.mjs
# One shared snapshot for every visitor. Only the 20-minute schedule can
# call TomTom: at most 2,232 requests in a 31-day month (89.28% of the
# documented 2,500/month free allowance). Pushes and manual runs only
# reuse the cached file. No retries, and no browser-side API calls.
- uses: actions/cache@v4
with:
path: public/data/roads/EGCC-traffic.json
key: tomtom-traffic-${{ github.run_id }}
restore-keys: tomtom-traffic-
- name: Refresh shared traffic incident snapshot
continue-on-error: true
env:
TOMTOM_KEY: ${{ secrets.TOMTOM_KEY }}
TOMTOM_PUBLISH_ALLOWED: ${{ vars.TOMTOM_PUBLISH_ALLOWED }}
TOMTOM_FETCH_SLOT: ${{ github.event_name == 'schedule' && github.event.schedule == '7,27,47 * * * *' && github.run_attempt == 1 }}
run: node scripts/fetch-tomtom-incidents.mjs
- run: npm run build
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4