-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (71 loc) · 2.17 KB
/
get-maps-and-charts.yml
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
name: Download maps and charts from backend and publish with GitHub Pages
# Schedule each day at 8:30am UTC (10:30 CEST, after data is published by authorities)
on:
workflow_dispatch:
schedule:
- cron: '30 8 * * *'
jobs:
download:
name: Download data from servers
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
# Get master branch to get executable
- uses: actions/checkout@v4
with:
ref: 'master'
# Used to transform JS (original data format) into JSON
- name: Use Node.js 14.x
uses: actions/setup-node@v4.0.3
with:
node-version: 14.x
- name: Prepare destination environment
run: |
mkdir -p newData
# Minimum info for repo and for web
cp README.md newData/
cp README.md newData/index.html
- name: Download Maps data and transform to SVG and JSON
run: |
mkdir -p newData/Maps
pushd ./newData/Maps
../../bin/download-map-data.sh
popd
- name: Download Charts data and transform to JSON
run: |
mkdir -p newData/Charts cache
# Install node dependencies (fetch)
pushd charts
npm install
popd
# Do the job until finished correctly
MAX=5
WAIT=60
while ! node charts/index.js cache newData/Charts
do
echo "[WARNING] Some files were not downloaded."
if (( DONE++ >= MAX ))
then
echo "[ERROR] Max reties ${DONE}/${MAX} reached. Exiting." >&2
exit 1
fi
echo "[WARNING] Retrying ${DONE}/${MAX} in ${WAIT} seconds..."
sleep ${WAIT}
done
- name: Download Barcelona data and transform to JSON
run: |
mkdir -p newData/Bcn cache
# Install node dependencies (fetch)
pushd bcn
npm install
popd
# Do the job
node bcn/index.js cache newData/Bcn
- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: newData
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}