@@ -20,40 +20,31 @@ concurrency:
20
20
cancel-in-progress : true
21
21
22
22
jobs :
23
- build :
24
- name : Build and publish Jetpack Dev Environment
23
+ prepare :
24
+ name : Prepare
25
25
runs-on : ubuntu-latest
26
26
permissions :
27
- packages : write
28
27
contents : read
29
- timeout-minutes : 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh.
28
+ timeout-minutes : 5 # 2025-03-04: Should be very fast.
29
+ outputs :
30
+ php-version : ${{ steps.buildargs.outputs.php-version }}
31
+ composer-version : ${{ steps.buildargs.outputs.composer-version }}
32
+ node-version : ${{ steps.buildargs.outputs.node-version }}
33
+ pnpm-version : ${{ steps.buildargs.outputs.pnpm-version }}
34
+ labels : ${{ steps.buildargs.outputs.labels }}
35
+ tags : ${{ steps.buildargs.outputs.tags }}
36
+ images : ${{ steps.buildargs.outputs.images }}
30
37
31
38
steps :
32
39
- uses : actions/checkout@v4
33
40
34
- - name : Set up qemu
35
- uses : docker/setup-qemu-action@v3
36
- with :
37
- platforms : arm64
38
-
39
- - name : Set up Docker Buildx
40
- uses : docker/setup-buildx-action@v3
41
-
42
- - name : Log in to Docker Hub
43
- uses : docker/login-action@v3
44
- with :
45
- username : matticbot
46
- password : ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
47
-
48
- - name : Log in to GitHub Packages
49
- uses : docker/login-action@v3
50
- with :
51
- registry : ghcr.io
52
- username : ${{ github.actor }}
53
- password : ${{ secrets.GITHUB_TOKEN }}
54
-
55
41
- name : Fetch build args
56
42
id : buildargs
43
+ env :
44
+ LABELS : |
45
+ org.opencontainers.image.title=Jetpack Development Environment
46
+ org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
47
+ org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
57
48
run : |
58
49
source .github/versions.sh
59
50
source .github/files/gh-funcs.sh
62
53
gh_set_output composer-version "$COMPOSER_VERSION"
63
54
gh_set_output node-version "$NODE_VERSION"
64
55
gh_set_output pnpm-version "$PNPM_VERSION"
56
+ gh_set_output labels "$LABELS"
65
57
66
58
# We're not git-tagging for the env. Just tag all trunk builds as latest.
67
59
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
@@ -75,28 +67,140 @@ jobs:
75
67
exit 1
76
68
fi
77
69
70
+ build :
71
+ name : Build Jetpack Dev Environment (${{ matrix.platform }})
72
+ runs-on : ${{ matrix.runner }}
73
+ needs : prepare
74
+ permissions :
75
+ packages : write
76
+ contents : read
77
+ timeout-minutes : 15 # 2025-03-04: Arm build takes about 5 minutes.
78
+ strategy :
79
+ matrix :
80
+ include :
81
+ - runner : ubuntu-latest
82
+ platform : amd64
83
+ - runner : ubuntu-24.04-arm
84
+ platform : arm64
85
+
86
+ steps :
87
+ - uses : actions/checkout@v4
88
+
89
+ - name : Set up Docker Buildx
90
+ uses : docker/setup-buildx-action@v3
91
+
92
+ - name : Log in to Docker Hub
93
+ uses : docker/login-action@v3
94
+ with :
95
+ username : matticbot
96
+ password : ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
97
+
98
+ - name : Log in to GitHub Packages
99
+ uses : docker/login-action@v3
100
+ with :
101
+ registry : ghcr.io
102
+ username : ${{ github.actor }}
103
+ password : ${{ secrets.GITHUB_TOKEN }}
104
+
78
105
- name : Extract Docker metadata
79
106
id : meta
80
107
uses : docker/metadata-action@v5
81
108
with :
82
109
flavor : latest=false
83
- tags : ${{ steps.buildargs.outputs.tags }}
84
- images : ${{ steps.buildargs.outputs.images }}
85
- labels : |
86
- org.opencontainers.image.title=Jetpack Development Environment
87
- org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
88
- org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
110
+ images : ${{ needs.prepare.outputs.images }}
111
+ labels : ${{ needs.prepare.outputs.labels }}
89
112
90
- - name : Build and push Docker image
113
+ - name : Build and push by digest
114
+ id : build
91
115
uses : docker/build-push-action@v6
92
116
with :
93
117
context : tools/docker
94
- platforms : linux/amd64,linux/arm64
95
- push : true
96
- tags : ${{ steps.meta .outputs.tags }}
118
+ platforms : linux/${{ matrix.platform }}
119
+ # For push by digest, the "tags" are just the images. We tag later.
120
+ tags : ${{ needs.prepare .outputs.images }}
97
121
labels : ${{ steps.meta.outputs.labels }}
122
+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
98
123
build-args : |
99
- PHP_VERSION=${{ steps.buildargs.outputs.php-version }}
100
- COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }}
101
- NODE_VERSION=${{ steps.buildargs.outputs.node-version }}
102
- PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }}
124
+ PHP_VERSION=${{ needs.prepare.outputs.php-version }}
125
+ COMPOSER_VERSION=${{ needs.prepare.outputs.composer-version }}
126
+ NODE_VERSION=${{ needs.prepare.outputs.node-version }}
127
+ PNPM_VERSION=${{ needs.prepare.outputs.pnpm-version }}
128
+
129
+ - name : Export digest
130
+ env :
131
+ TEMP : ${{ runner.temp }}
132
+ DIGEST : ${{ steps.build.outputs.digest }}
133
+ run : |
134
+ mkdir -p "$TEMP/digests"
135
+ touch "$TEMP/digests/${DIGEST#sha256:}"
136
+
137
+ - name : Upload digest
138
+ uses : actions/upload-artifact@v4
139
+ with :
140
+ name : digests-linux-${{ matrix.platform }}
141
+ path : ${{ runner.temp }}/digests/*
142
+ if-no-files-found : error
143
+ retention-days : 1
144
+
145
+ merge :
146
+ name : Merge and publish Jetpack Dev Environment
147
+ runs-on : ubuntu-latest
148
+ needs : [ prepare, build ]
149
+ permissions :
150
+ packages : write
151
+ contents : read
152
+ timeout-minutes : 10 # 2025-03-04: Merge takes about 5? minutes.
153
+
154
+ steps :
155
+ - name : Download digests
156
+ uses : actions/download-artifact@v4
157
+ with :
158
+ path : ${{ runner.temp }}/digests
159
+ pattern : digests-*
160
+ merge-multiple : true
161
+
162
+ - name : Set up Docker Buildx
163
+ uses : docker/setup-buildx-action@v3
164
+
165
+ - name : Log in to Docker Hub
166
+ uses : docker/login-action@v3
167
+ with :
168
+ username : matticbot
169
+ password : ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
170
+
171
+ - name : Log in to GitHub Packages
172
+ uses : docker/login-action@v3
173
+ with :
174
+ registry : ghcr.io
175
+ username : ${{ github.actor }}
176
+ password : ${{ secrets.GITHUB_TOKEN }}
177
+
178
+ - name : Extract Docker metadata
179
+ id : meta
180
+ uses : docker/metadata-action@v5
181
+ with :
182
+ flavor : latest=false
183
+ tags : ${{ needs.prepare.outputs.tags }}
184
+ images : ${{ needs.prepare.outputs.images }}
185
+ labels : ${{ needs.prepare.outputs.labels }}
186
+
187
+ - name : Create manifest list and push
188
+ working-directory : ${{ runner.temp }}/digests
189
+ env :
190
+ IMAGES : ${{ needs.prepare.outputs.images }}
191
+ run : |
192
+ while IFS= read -r IMAGE; do
193
+ echo "=== $IMAGE ==="
194
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
195
+ $(printf "$IMAGE@sha256:%s " *)
196
+ done
197
+
198
+ - name : Inspect image
199
+ env :
200
+ IMAGES : ${{ needs.prepare.outputs.images }}
201
+ VERSION : ${{ steps.meta.outputs.version }}
202
+ run : |
203
+ while IFS= read -r IMAGE; do
204
+ echo "=== $IMAGE ==="
205
+ docker buildx imagetools inspect "$IMAGE:$VERSION"
206
+ done
0 commit comments