-
Notifications
You must be signed in to change notification settings - Fork 1
295 lines (290 loc) · 10.1 KB
/
test-release-build.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Docker CI
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TILESET_NAME: trees.mbtiles
TILESET_DIR: /tilesets
TMP_DIR: /tmp
GEOJSON_OUTPUT_DIR: /tmp
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_BUCKET: ${{ secrets.AWS_TEST_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
POSTGRES_MATERIALIZE_VIEW_NAME: "vector_tiles"
GEOJSON_OUTPUT_FILENAME: "trees.geo.json"
DEFAULT_BASE_IMAGE: technologiestiftung/qtrees-vectortiles_base:latest
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
on:
push:
branches: [main, staging]
tags:
- "v*"
pull_request:
branches: [main, staging]
workflow_dispatch:
inputs:
debug_enabled:
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
release:
types: [published]
jobs:
test:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
steps:
- name: Checkout technologiestiftung/qtrees-vectortiles
uses: actions/checkout@v4
- name: base image test via docker compose
env:
GITHUB_TOKEN: ${{secrets.GH_PA_TOKEN}}
run: |
docker build --tag qtrees-vectortiles_base:test --file ./Dockerfile.base .
docker compose --file docker-compose.yml --file docker-compose.test.yml up --abort-on-container-exit --no-color --exit-code-from mbtileserver
- name: Tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 5
with:
limit-access-to-actor: true
test-generator:
needs:
- test
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
steps:
- name: Checkout technologiestiftung/qtrees-vectortiles
uses: actions/checkout@v4
- name: Run generator using docker compose
env:
POSTGRES_HOST: ${{env.POSTGRES_HOST}}
POSTGRES_DB: ${{env.POSTGRES_DB}}
POSTGRES_USER: ${{env.POSTGRES_USER}}
POSTGRES_PASSWORD: ${{env.POSTGRES_PASSWORD}}
POSTGRES_PORT: ${{env.POSTGRES_PORT}}
TILESET_DIR: ${{env.TILESET_DIR}}
TILESET_NAME: ${{env.TILESET_NAME}}
TMP_DIR: ${{env.TMP_DIR}}
POSTGRES_MATERIALIZE_VIEW_NAME: ${{env.POSTGRES_MATERIALIZE_VIEW_NAME}}
POSTGREST_API_URL: ${{env.POSTGREST_API_URL}}
GEOJSON_OUTPUT_FILENAME: ${{env.GEOJSON_OUTPUT_FILENAME}}
GEOJSON_OUTPUT_DIR: ${{env.TMP_DIR}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{env.AWS_DEFAULT_REGION}}
AWS_BUCKET: ${{ secrets.AWS_TEST_BUCKET }}
run: |
docker compose -f docker-compose.generator.yml up --abort-on-container-exit --no-color --exit-code-from generator
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- run: npm ci
- name: Run node tests
env:
TEST_GEOJSON_FILE_PATH: ${{env.TMP_DIR}}/${{env.GEOJSON_OUTPUT_FILENAME}}
run: npm run test:ci
- name: Tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 5
with:
limit-access-to-actor: true
release:
name: Release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs:
- test
- test-generator
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
build-and-push-docker-hub:
needs:
- test
- test-generator
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Checkout source repository
uses: actions/checkout@v4
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
- name: Docker meta base
id: meta_base
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}_base
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Docker meta server
id: meta_server
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}_server
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Docker meta generator
id: meta_generator
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}_generator
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build base
uses: docker/build-push-action@v3
with:
# load: true
# platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.base
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_base.outputs.tags }}
labels: ${{ steps.meta_base.outputs.labels }}
- name: Build Server
uses: docker/build-push-action@v3
with:
# load: true
# platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.server
build-args: |
BASE_IMAGE=${{ steps.meta_base.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_server.outputs.tags }}
labels: ${{ steps.meta_server.outputs.labels }}
- name: Build Generator
uses: docker/build-push-action@v3
with:
# load: true
# platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.generator
build-args: |
BASE_IMAGE=${{ steps.meta_base.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_generator.outputs.tags }}
labels: ${{ steps.meta_generator.outputs.labels }}
# We dont use ghcr yet. This is more like a redundanc backup
build-and-push-ghcr:
env:
REGISTRY: ghcr.io
needs:
- test
- test-generator
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker base
id: metaghcr_base
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_base
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Extract metadata (tags, labels) for Docker server
id: metaghcr_server
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_server
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Extract metadata (tags, labels) for Docker generator
id: metaghcr_generator
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_generator
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build base and push
uses: docker/build-push-action@v3
with:
# load: true
# platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.base
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metaghcr_base.outputs.tags }}
labels: ${{ steps.metaghcr_base.outputs.labels }}
- name: Build server and push
uses: docker/build-push-action@v3
with:
# load: true
# platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.server
build-args: |
BASE_IMAGE=${{ steps.metaghcr_base.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metaghcr_server.outputs.tags }}
labels: ${{ steps.metaghcr_server.outputs.labels }}
- name: Build generator and push
uses: docker/build-push-action@v3
with:
# load: true
# platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.generator
build-args: |
BASE_IMAGE=${{ steps.metaghcr_base.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metaghcr_generator.outputs.tags }}
labels: ${{ steps.metaghcr_generator.outputs.labels }}