generated from EVerest/everest-template
-
Notifications
You must be signed in to change notification settings - Fork 5
199 lines (194 loc) · 9.12 KB
/
deploy-docker-images.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: Build and push docker images
on:
workflow_dispatch:
inputs:
force_rebuild:
description: 'Force rebuild of all images'
default: false
type: boolean
build_deprecated_images:
description: 'Build deprecated images'
default: false
type: boolean
push:
branches:
- '**'
tags:
- 'v*'
env:
REGISTRY: ghcr.io
DOCKER_DIRECTORY: docker/images
PLATFORMS: |
linux/amd64
PATH_TO_DEPLOY_SINGLE_DOCKER_IMAGE_WORKFLOW: .github/workflows/deploy-single-docker-image.yml
PATH_TO_DEPLOY_DOCKER_IMAGES_WORKFLOW: .github/workflows/deploy-docker-images.yml
jobs:
env-setup:
# Since env variables can't be passed to reusable workflows, we need to pass them as outputs
name: Evaluate force rebuild and set env variables as outputs
runs-on: ubuntu-22.04
outputs:
force_rebuild: ${{ steps.check.outputs.force_rebuild }}
docker_registry: ${{ env.REGISTRY }}
docker_directory: ${{ env.DOCKER_DIRECTORY }}
platforms: ${{ env.PLATFORMS }}
repository_name: ${{ github.event.repository.name }}
build_deprecated_images: ${{ steps.check.outputs.build_deprecated_images }}
path_to_deploy_single_docker_image_workflow: ${{ env.PATH_TO_DEPLOY_SINGLE_DOCKER_IMAGE_WORKFLOW }}
path_to_deploy_docker_images_workflow: ${{ env.PATH_TO_DEPLOY_DOCKER_IMAGES_WORKFLOW }}
steps:
- id: check
run: |
echo "force_rebuild=${{ inputs.force_rebuild || (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/' )) || false }}" >> $GITHUB_OUTPUT
# Build deprecated images if not explicitly disabled
#TODO: set default to false, once backwards compatibility is no longer needed
echo "build_deprecated_images=${{ inputs.build_deprecated_images || true }}" >> $GITHUB_OUTPUT
# One job for each image, since the images build on top of each other a matrix strategy is not possible
run-env-base:
needs:
- env-setup
name: Build and push run-env-base docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/run-env-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/run-env-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build-env-base:
needs:
- env-setup
- run-env-base
name: Build and push build-env-base docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' || needs.run-env-base.outputs.rebuild == 'true' }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/build-env-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/build-env-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build_args: |
BASE_IMAGE_TAG=${{ needs.run-env-base.outputs.one_image_tag_short }}
dev-env-base:
needs:
- env-setup
- build-env-base
name: Build and push dev-env-base docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' || needs.build-env-base.outputs.rebuild == 'true' }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/dev-env-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/dev-env-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build_args: |
BASE_IMAGE_TAG=${{ needs.build-env-base.outputs.one_image_tag_short }}
build-kit-base:
needs:
- env-setup
- build-env-base
name: Build and push build-kit docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' || needs.build-env-base.outputs.rebuild == 'true' }}
image_name: ${{ needs.env-setup.outputs.repository_name }}/build-kit-base
directory: ${{ needs.env-setup.outputs.docker_directory }}/build-kit-base
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build_args: |
BASE_IMAGE_TAG=${{ needs.build-env-base.outputs.one_image_tag_short }}
# Include deprecated images for backwards compatibility
deprecated-everest-clang-format:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
needs:
- env-setup
name: Build and push deprecated everest-clang-format docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: everest-clang-format
directory: docker/deprecated-images/everest-clang-format
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
deprecated-build-kit-alpine:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
needs:
- env-setup
name: Build and push deprecated build-kit-alpine docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: build-kit-alpine
directory: docker/deprecated-images/build-kit
docker_file_name: alpine.Dockerfile
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
deprecated-build-kit-debian:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
needs:
- env-setup
name: Build and push deprecated build-kit-debian docker image
uses: ./.github/workflows/deploy-single-docker-image.yml
secrets:
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }}
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }}
with:
force_rebuild: ${{ needs.env-setup.outputs.force_rebuild == 'true' }}
image_name: build-kit-debian
directory: docker/deprecated-images/build-kit
docker_file_name: debian.Dockerfile
docker_registry: ${{ needs.env-setup.outputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: ${{ needs.env-setup.outputs.platforms }}
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}