Skip to content

Commit 69006f8

Browse files
authored
ci(docker): Use docker/build-push-action@v4 (#544)
1 parent 84b7863 commit 69006f8

File tree

2 files changed

+162
-48
lines changed

2 files changed

+162
-48
lines changed

.github/workflows/deploy-master.yml

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,71 @@ jobs:
1515
steps:
1616
- name: Check out the repo
1717
uses: actions/checkout@v3
18-
- name: Push to Docker Hub
19-
uses: docker/build-push-action@v1
18+
- name: Set up Docker Buildx
19+
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
20+
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
21+
uses: docker/setup-buildx-action@v2
22+
with:
23+
driver: "docker"
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v2
2026
with:
21-
always_pull: true
22-
add_git_labels: true
23-
labels: "org.opencontainers.image.version=master"
2427
username: ${{ secrets.DOCKER_USERNAME }}
2528
password: ${{ secrets.DOCKER_PASSWORD }}
26-
repository: ocamlsf/learn-ocaml
27-
tags: master
29+
- name: Prepare
30+
id: prep
31+
run: |
32+
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
33+
- name: Push to Docker Hub
34+
# cf. https://github.com/docker/build-push-action#customizing
35+
# and https://github.com/docker/build-push-action/pull/119
36+
uses: docker/build-push-action@v4
37+
with:
38+
pull: true
39+
push: true
40+
tags: "ocamlsf/learn-ocaml:master"
41+
labels: |
42+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
43+
org.opencontainers.image.source=${{ github.repositoryUrl }}
44+
org.opencontainers.image.version=master
45+
org.opencontainers.image.revision=${{ github.sha }}
2846
push_client:
2947
name: Push learn-ocaml-client image to Docker Hub
3048
if: ${{ github.repository == 'ocaml-sf/learn-ocaml' }}
3149
runs-on: ubuntu-latest
3250
steps:
3351
- name: Check out the repo
3452
uses: actions/checkout@v3
35-
- name: Push to Docker Hub
36-
uses: docker/build-push-action@v1
53+
- name: Set up Docker Buildx
54+
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
55+
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
56+
uses: docker/setup-buildx-action@v2
57+
with:
58+
driver: "docker"
59+
- name: Login to Docker Hub
60+
uses: docker/login-action@v2
3761
with:
38-
always_pull: true
39-
add_git_labels: true
40-
labels: "org.opencontainers.image.version=master"
4162
username: ${{ secrets.DOCKER_USERNAME }}
4263
password: ${{ secrets.DOCKER_PASSWORD }}
43-
repository: ocamlsf/learn-ocaml-client
64+
- name: Prepare
65+
id: prep
66+
run: |
67+
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
68+
- name: Push to Docker Hub
69+
# cf. https://github.com/docker/build-push-action#customizing
70+
# and https://github.com/docker/build-push-action/pull/119
71+
uses: docker/build-push-action@v4
72+
with:
73+
pull: true
74+
# load: true # implied by "driver: docker"
75+
push: true
4476
target: client
45-
tags: master
77+
tags: "ocamlsf/learn-ocaml-client:master"
78+
labels: |
79+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
80+
org.opencontainers.image.source=${{ github.repositoryUrl }}
81+
org.opencontainers.image.version=master
82+
org.opencontainers.image.revision=${{ github.sha }}
4683
push_emacs_client:
4784
name: Push emacs-learn-ocaml-client image to Docker Hub
4885
if: ${{ github.repository == 'ocaml-sf/learn-ocaml' }}
@@ -51,16 +88,33 @@ jobs:
5188
steps:
5289
- name: Check out the repo
5390
uses: actions/checkout@v3
54-
- name: Push to Docker Hub
55-
# https://github.com/docker/build-push-action/tree/releases/v1#readme
56-
uses: docker/build-push-action@v1
91+
- name: Set up Docker Buildx
92+
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
93+
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
94+
uses: docker/setup-buildx-action@v2
95+
with:
96+
driver: "docker"
97+
- name: Login to Docker Hub
98+
uses: docker/login-action@v2
5799
with:
58-
path: ci/docker-emacs-learn-ocaml-client
59-
build_args: "base=ocamlsf/learn-ocaml-client,version=master"
60-
always_pull: true
61-
add_git_labels: true
62-
labels: "org.opencontainers.image.version=master"
63100
username: ${{ secrets.DOCKER_USERNAME }}
64101
password: ${{ secrets.DOCKER_PASSWORD }}
65-
repository: ocamlsf/emacs-learn-ocaml-client
66-
tags: master
102+
- name: Prepare
103+
id: prep
104+
run: |
105+
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
106+
- name: Push to Docker Hub
107+
# cf. https://github.com/docker/build-push-action#customizing
108+
# and https://github.com/docker/build-push-action/pull/119
109+
uses: docker/build-push-action@v4
110+
with:
111+
pull: false # because of the previous "load: true"
112+
push: true
113+
context: ci/docker-emacs-learn-ocaml-client
114+
build_args: "base=ocamlsf/learn-ocaml-client,version=master"
115+
tags: "ocamlsf/emacs-learn-ocaml-client:master"
116+
labels: |
117+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
118+
org.opencontainers.image.source=${{ github.repositoryUrl }}
119+
org.opencontainers.image.version=master
120+
org.opencontainers.image.revision=${{ github.sha }}

.github/workflows/release.yml

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,36 @@ jobs:
134134
id: tag
135135
- name: Check out the repo
136136
uses: actions/checkout@v3
137-
- name: Push to Docker Hub
138-
uses: docker/build-push-action@v1
137+
- name: Set up Docker Buildx
138+
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
139+
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
140+
uses: docker/setup-buildx-action@v2
141+
with:
142+
driver: "docker"
143+
- name: Login to Docker Hub
144+
uses: docker/login-action@v2
139145
with:
140-
always_pull: true
141-
add_git_labels: true
142-
labels: "org.opencontainers.image.version=${{ steps.tag.outputs.tag }}"
143146
username: ${{ secrets.DOCKER_USERNAME }}
144147
password: ${{ secrets.DOCKER_PASSWORD }}
145-
repository: ocamlsf/learn-ocaml
146-
tags: "latest,${{ steps.tag.outputs.tag }}"
148+
- name: Prepare
149+
id: prep
150+
run: |
151+
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
152+
- name: Push to Docker Hub
153+
# cf. https://github.com/docker/build-push-action#customizing
154+
# and https://github.com/docker/build-push-action/pull/119
155+
uses: docker/build-push-action@v4
156+
with:
157+
pull: true
158+
push: true
159+
tags: |
160+
ocamlsf/learn-ocaml:latest
161+
ocamlsf/learn-ocaml:${{ steps.tag.outputs.tag }}
162+
labels: |
163+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
164+
org.opencontainers.image.source=${{ github.repositoryUrl }}
165+
org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
166+
org.opencontainers.image.revision=${{ github.sha }}
147167
push_client:
148168
needs: [release-please]
149169
if: ${{ needs.release-please.outputs.release_created }}
@@ -155,17 +175,38 @@ jobs:
155175
id: tag
156176
- name: Check out the repo
157177
uses: actions/checkout@v3
158-
- name: Push to Docker Hub
159-
uses: docker/build-push-action@v1
178+
- name: Set up Docker Buildx
179+
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
180+
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
181+
uses: docker/setup-buildx-action@v2
182+
with:
183+
driver: "docker"
184+
- name: Login to Docker Hub
185+
uses: docker/login-action@v2
160186
with:
161-
always_pull: true
162-
add_git_labels: true
163-
labels: "org.opencontainers.image.version=${{ steps.tag.outputs.tag }}"
164187
username: ${{ secrets.DOCKER_USERNAME }}
165188
password: ${{ secrets.DOCKER_PASSWORD }}
166-
repository: ocamlsf/learn-ocaml-client
189+
- name: Prepare
190+
id: prep
191+
run: |
192+
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
193+
- name: Push to Docker Hub
194+
# cf. https://github.com/docker/build-push-action#customizing
195+
# and https://github.com/docker/build-push-action/pull/119
196+
uses: docker/build-push-action@v4
197+
with:
198+
pull: true
199+
# load: true # implied by "driver: docker"
200+
push: true
167201
target: client
168-
tags: "latest,${{ steps.tag.outputs.tag }}"
202+
tags: |
203+
ocamlsf/learn-ocaml-client:latest
204+
ocamlsf/learn-ocaml-client:${{ steps.tag.outputs.tag }}
205+
labels: |
206+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
207+
org.opencontainers.image.source=${{ github.repositoryUrl }}
208+
org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
209+
org.opencontainers.image.revision=${{ github.sha }}
169210
push_emacs_client:
170211
needs:
171212
- release-please
@@ -179,16 +220,35 @@ jobs:
179220
id: tag
180221
- name: Check out the repo
181222
uses: actions/checkout@v3
182-
- name: Push to Docker Hub
183-
# https://github.com/docker/build-push-action/tree/releases/v1#readme
184-
uses: docker/build-push-action@v1
223+
- name: Set up Docker Buildx
224+
# cf. https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#image
225+
# and https://docs.docker.com/engine/reference/commandline/buildx_create/#driver
226+
uses: docker/setup-buildx-action@v2
227+
with:
228+
driver: "docker"
229+
- name: Login to Docker Hub
230+
uses: docker/login-action@v2
185231
with:
186-
path: ci/docker-emacs-learn-ocaml-client
187-
build_args: "base=ocamlsf/learn-ocaml-client,version=${{ steps.tag.outputs.tag }}"
188-
always_pull: true
189-
add_git_labels: true
190-
labels: "org.opencontainers.image.version=${{ steps.tag.outputs.tag }}"
191232
username: ${{ secrets.DOCKER_USERNAME }}
192233
password: ${{ secrets.DOCKER_PASSWORD }}
193-
repository: ocamlsf/emacs-learn-ocaml-client
194-
tags: ${{ steps.tag.outputs.tag }}
234+
- name: Prepare
235+
id: prep
236+
run: |
237+
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
238+
- name: Push to Docker Hub
239+
# cf. https://github.com/docker/build-push-action#customizing
240+
# and https://github.com/docker/build-push-action/pull/119
241+
uses: docker/build-push-action@v4
242+
with:
243+
pull: false # because of the previous "load: true"
244+
push: true
245+
context: ci/docker-emacs-learn-ocaml-client
246+
build_args: "base=ocamlsf/learn-ocaml-client,version=${{ steps.tag.outputs.tag }}"
247+
tags: |
248+
ocamlsf/emacs-learn-ocaml-client:latest
249+
ocamlsf/emacs-learn-ocaml-client:${{ steps.tag.outputs.tag }}
250+
labels: |
251+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
252+
org.opencontainers.image.source=${{ github.repositoryUrl }}
253+
org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
254+
org.opencontainers.image.revision=${{ github.sha }}

0 commit comments

Comments
 (0)