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