-
Notifications
You must be signed in to change notification settings - Fork 0
276 lines (243 loc) · 8.43 KB
/
build-server.yaml
File metadata and controls
276 lines (243 loc) · 8.43 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
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
name: Build and Push Docker Image Server
on:
workflow_dispatch:
push:
paths:
- "rust/common/**"
- "rust/server/**"
- "rust/Cargo.toml"
- "rust/Cargo.lock"
- "rust/Dockerfile"
- ".docker/**"
- "pbf-patch/**"
- ".github/workflows/**"
branches:
- develop
jobs:
setup:
runs-on: ubuntu-latest
outputs:
COMMIT_SHA: ${{ steps.set_commit_sha.outputs.COMMIT_SHA }}
REPO_LC: ${{ steps.set_repo_lc.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set commit sha
id: set_commit_sha
run: |
COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT
- name: set lower case owner name
id: set_repo_lc
run: |
echo "REPO_LC=${REPO,,}" >>${GITHUB_ENV}
echo "REPO_LC=${REPO,,}" >>${GITHUB_OUTPUT}
env:
REPO: "${{ github.repository }}"
build-server:
runs-on: ubuntu-latest
permissions:
packages: write
needs: setup
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
target: runtime-both
context: rust
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ghcr.io/${{ env.REPO_LC }}/server:dev, ghcr.io/${{ env.REPO_LC }}/server:${{ env.COMMIT_SHA }}
build-cleanup:
runs-on: ubuntu-latest
permissions:
packages: write
needs: setup
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .docker
file: .docker/Dockerfile.cleanup
push: true
tags: ghcr.io/${{ env.REPO_LC }}/cleanup-tiles:dev, ghcr.io/${{ env.REPO_LC }}/cleanup-tiles:${{ env.COMMIT_SHA }}
build-sync:
runs-on: ubuntu-latest
permissions:
packages: write
needs: setup
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .docker
file: .docker/Dockerfile.sync
push: true
tags: ghcr.io/${{ env.REPO_LC }}/sync:dev, ghcr.io/${{ env.REPO_LC }}/sync:${{ env.COMMIT_SHA }}
build-pbf-patch:
runs-on: ubuntu-latest
permissions:
packages: write
needs: setup
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: pbf-patch
push: true
tags: ghcr.io/${{ env.REPO_LC }}/pbf-patch:dev, ghcr.io/${{ env.REPO_LC }}/pbf-patch:${{ env.COMMIT_SHA }}
build-valhalla:
runs-on: ubuntu-latest
permissions:
packages: write
needs: setup
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .docker
file: .docker/Dockerfile.valhalla
push: true
tags: ghcr.io/${{ env.REPO_LC }}/generate-valhalla:dev, ghcr.io/${{ env.REPO_LC }}/generate-valhalla:${{ env.COMMIT_SHA }}
build-osrm:
runs-on: ubuntu-latest
permissions:
packages: write
needs: setup
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .docker
file: .docker/Dockerfile.osrm
push: true
tags: ghcr.io/${{ env.REPO_LC }}/generate-osrm:dev, ghcr.io/${{ env.REPO_LC }}/generate-osrm:${{ env.COMMIT_SHA }}
commit_k8s_stage_image:
runs-on: ubuntu-latest
needs:
- setup
- build-server
- build-sync
- build-cleanup
- build-pbf-patch
- build-valhalla
- build-osrm
env:
COMMIT_SHA: ${{ needs.setup.outputs.COMMIT_SHA }}
REPO_LC: ${{ needs.setup.outputs.REPO_LC }}
steps:
- name: Get Green Ecolution App Token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: write
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Get Green Ecolution App User ID
id: get-user-id
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: Initialize mandatory git config
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
- name: Bump k8s stage image tag
run: |
cd ./deploy/kustomize/stage
kustomize edit set image sync-image=ghcr.io/${{ env.REPO_LC }}/sync:${{ env.COMMIT_SHA }}
kustomize edit set image cleanup-tiles-image=ghcr.io/${{ env.REPO_LC }}/cleanup-tiles:${{ env.COMMIT_SHA }}
kustomize edit set image pbf-patch-image=ghcr.io/${{ env.REPO_LC }}/pbf-patch:${{ env.COMMIT_SHA }}
kustomize edit set image server-image=ghcr.io/${{ env.REPO_LC }}/server:${{ env.COMMIT_SHA }}
kustomize edit set image generate-osrm-image=ghcr.io/${{ env.REPO_LC }}/generate-osrm:${{ env.COMMIT_SHA }}
kustomize edit set image generate-valhalla-image=ghcr.io/${{ env.REPO_LC }}/generate-valhalla:${{ env.COMMIT_SHA }}
- name: Commit changes
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git add deploy/kustomize/stage/kustomization.yaml
git commit -m "chore: update stage image tag [skip ci]" && git push origin develop