forked from alphagov/paas-docker-cloudfoundry-tools
-
Notifications
You must be signed in to change notification settings - Fork 3
229 lines (217 loc) · 7.3 KB
/
docker-image.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
name: Build and Publish Docker Images
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
#DOCKERHUB_ORG: orangecloudfoundry
DOCKERHUB_ORG: elpaasoci
BASE_IMAGES: cf-cli curl-ssl git-ssh k8s-tools terraform bosh-cli-v2 spruce
IMAGES_WITH_DEPENDENCIES: awscli bosh-cli-v2-cf-cli
jobs:
build_and_publish:
name: build, test and publish
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: build docker images
run: | # shellcheck disable=SC2086
for image in $BASE_IMAGES;do
echo "Processing $image"
bundle exec rake build:$image
done
-
name: test docker images
run: | # shellcheck disable=SC2086
for image in $BASE_IMAGES;do
echo "Processing $image"
bundle exec rake spec:$image
done
-
name: publish curl-ssl image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: curl-ssl
-
name: publish git-ssh image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: git-ssh
-
name: publish cf-cli image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: cf-cli
-
name: publish k8s-tools image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: k8s-tools
-
name: publish bosh-cli-v2 image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: bosh-cli-v2
-
name: publish terraform image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: terraform
-
name: publish spruce image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: spruce
-
name: build docker images with dependencies
run: | # shellcheck disable=SC2086
for image in $IMAGES_WITH_DEPENDENCIES;do
echo "Processing $image"
bundle exec rake build:$image
done
-
name: test docker images with dependencies
run: |# shellcheck disable=SC2086
for image in $IMAGES_WITH_DEPENDENCIES;do
echo "Processing $image"
bundle exec rake spec:$image
done
-
name: publish awscli image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: awscli
-
name: publish bosh-cli-v2-cf-cli image
uses: docker/build-push-action@v6.7.0
with:
context: ${{env.IMAGE}}
push: true
tags: |
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:latest
${{env.DOCKERHUB_ORG}}/${{env.IMAGE}}:${{github.sha}}
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:latest
ghcr.io/${{ github.repository }}/${{env.IMAGE}}:${{github.sha}}
env:
IMAGE: bosh-cli-v2-cf-cli
check_published_images:
name: check published images
runs-on: ubuntu-latest
needs: [ build_and_publish ]
steps:
- # Currently we cannot use `docker manifest` without authentication, it results in "unauthorized: access token has insufficient scopes"
# Also, to save network bandwidth and reduce build time we avoid using `docker pull`
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: check docker public images
run: | # shellcheck disable=SC2086
for image in $BASE_IMAGES $IMAGES_WITH_DEPENDENCIES;do
echo "Processing $image: checking manifest for $DOCKERHUB_ORG/$image:$GITHUB_SHA"
docker manifest inspect $DOCKERHUB_ORG/$image:$GITHUB_SHA
done
push_for_renovate:
name: Publish commit for renovate
runs-on: ubuntu-latest
needs: [ check_published_images ]
steps:
- uses: actions/checkout@v4
with:
ref: main
if: ${{ github.ref_name == 'main' }}
-
name: push
uses: github-actions-x/commit@v2.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
push-branch: 'main-validated'
force-push: true
if: ${{ github.ref_name == 'main' }}