forked from OpenRailwayMap/OpenRailwayMap-CartoCSS
-
Notifications
You must be signed in to change notification settings - Fork 2
199 lines (171 loc) · 5.48 KB
/
deploy.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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Deploy
on:
workflow_dispatch: ~
jobs:
deploy-proxy:
name: Deploy proxy
runs-on: ubuntu-latest
environment: proxy-production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup Fly
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl deploy --config proxy.fly.toml --local-only
# Import steps
# - name: Install Osmium
# run: |
# sudo apt install osmium-tool
# - name: Generate cache key
# id: cache-key
# run: |
# echo "key=$(date +%Y-%W)" >> $GITHUB_OUTPUT
# - name: Cache downloaded OpenStreetMap data
# id: cache-data
# uses: actions/cache@v4
# with:
# key: 'data-europe-${{ steps.cache-key.outputs.key }}'
# path: data/filtered/europe.osm.pbf
#
# - name: Download data
# if: ${{ steps.cache-data.outputs.cache-hit != 'true' }}
# run: |
# curl --progress-bar http://ftp.snt.utwente.nl/pub/misc/openstreetmap/europe-latest.osm.pbf --output data/europe.osm.pbf
# - name: Import data
# env:
# # Available cores: 4
# OSM2PGSQL_NUMPROC: 4
# # Available memory: 16GB
# OSM2PGSQL_CACHE: 14000
# OSM2PGSQL_DATAFILE: europe.osm.pbf
# run: |
# docker compose pull import
# docker compose build import
# docker compose run import import
# docker compose push import
# update-data:
# name: Update data
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# # The disk and memory in the Github runners is too small to do large imports.
# # A Docker image with a pre-imported database state is used.
# # During the deployment run, the docker image is updated through the replication updated,
# # comitted to a new image and pushed for future used.
# - name: Pull import database
# run: |
# docker compose pull db
# docker image ls ghcr.io/hiddewie/openrailwaymap-import-db:latest
# docker compose up --no-build --pull never --detach db
#
# - name: Ensure data is up to date
# env:
# # Available cores: 4
# OSM2PGSQL_NUMPROC: 4
# # Available memory: 16GB
# OSM2PGSQL_CACHE: 14000
# run: |
# docker compose pull import
# docker compose build import
# docker compose run import update
# docker compose push import
#
# - name: Commit and push new database image
# run: |
# docker compose stop db
# DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')"
# DB_IMAGE="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .Image')"
# docker commit "$DB_CONTAINER_ID" "$DB_IMAGE"
# docker image ls "$DB_IMAGE"
# docker push "$DB_IMAGE"
generate-tiles:
name: Generate tiles
runs-on: ubuntu-latest
# needs: update-data
strategy:
matrix:
tiles:
- low-med
- standard
- speed
- signals
- electrification
- gauge
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull import database
run: |
docker compose pull db
docker compose up --no-build --pull never --detach db
- name: Generate tiles
env:
TILES: ${{ matrix.tiles }}
run: |
docker compose run martin-cp
ls -las tiles/
- uses: actions/upload-artifact@v4
with:
name: tiles-${{ matrix.tiles }}
path: |
tiles/*.mbtiles
if-no-files-found: error
retention-days: 3
deploy-tiles:
name: Deploy tiles
runs-on: ubuntu-latest
needs: generate-tiles
environment: tiles-production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup Fly
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
# No name: download everything
path: tiles
merge-multiple: true
- name: List generated tiles
run: |
ls -lah tiles/
- name: Deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl deploy --config martin-static.fly.toml --local-only