@@ -21,20 +21,108 @@ concurrency:
21
21
22
22
jobs :
23
23
build :
24
- name : Build and publish Jetpack Dev Environment
25
- runs-on : ubuntu-latest
24
+ name : Build Jetpack Dev Environment (${{ matrix.platform }})
25
+ runs-on : ${{ matrix.runner }}
26
26
permissions :
27
27
packages : write
28
28
contents : read
29
29
timeout-minutes : 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh.
30
+ strategy :
31
+ matrix :
32
+ include :
33
+ - runner : ubuntu-latest
34
+ platform : amd64
35
+ - runner : ubuntu-24.04-arm
36
+ platform : arm64
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
41
+ - name : Set up Docker Buildx
42
+ uses : docker/setup-buildx-action@v3
43
+
44
+ - name : Fetch build args
45
+ id : buildargs
46
+ run : |
47
+ source .github/versions.sh
48
+ source .github/files/gh-funcs.sh
49
+
50
+ gh_set_output php-version "$PHP_VERSION"
51
+ gh_set_output composer-version "$COMPOSER_VERSION"
52
+ gh_set_output node-version "$NODE_VERSION"
53
+ gh_set_output pnpm-version "$PNPM_VERSION"
54
+
55
+ # We're not git-tagging for the env. Just tag all trunk builds as latest.
56
+ if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
57
+ gh_set_output tags "type=raw,latest"
58
+ gh_set_output images $'automattic/jetpack-wordpress-dev\nghcr.io/automattic/jetpack-wordpress-dev'
59
+ elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
60
+ gh_set_output tags "type=ref,event=pr"
61
+ gh_set_output images "ghcr.io/automattic/jetpack-wordpress-dev"
62
+ else
63
+ echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME"
64
+ exit 1
65
+ fi
66
+
67
+ - name : Extract Docker metadata
68
+ id : meta
69
+ uses : docker/metadata-action@v5
70
+ with :
71
+ flavor : latest=false
72
+ tags : ${{ steps.buildargs.outputs.tags }}
73
+ images : ${{ steps.buildargs.outputs.images }}
74
+ labels : |
75
+ org.opencontainers.image.title=Jetpack Development Environment
76
+ org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
77
+ org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
78
+
79
+ - name : Build and push by digest
80
+ id : build
81
+ uses : docker/build-push-action@v6
36
82
with :
37
- platforms : arm64
83
+ context : tools/docker
84
+ platforms : linux/${{ matrix.platform }}
85
+ tags : ${{ steps.meta.outputs.tags }}
86
+ labels : ${{ steps.meta.outputs.labels }}
87
+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
88
+ build-args : |
89
+ PHP_VERSION=${{ steps.buildargs.outputs.php-version }}
90
+ COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }}
91
+ NODE_VERSION=${{ steps.buildargs.outputs.node-version }}
92
+ PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }}
93
+
94
+ - name : Export digest
95
+ env :
96
+ TEMP : ${{ runner.temp }}
97
+ DIGEST : ${{ steps.build.outputs.digest }}
98
+ run : |
99
+ mkdir -p "$TEMP/digests"
100
+ touch "$TEMP/digests/${DIGEST#sha256:}"
101
+
102
+ - name : Upload digest
103
+ uses : actions/upload-artifact@v4
104
+ with :
105
+ name : digests-linux-${{ matrix.platform }}
106
+ path : ${{ runner.temp }}/digests/*
107
+ if-no-files-found : error
108
+ retention-days : 1
109
+
110
+ merge :
111
+ name : Merge and publish Jetpack Dev Environment
112
+ runs-on : ubuntu-latest
113
+ needs : build
114
+ permissions :
115
+ packages : write
116
+ contents : read
117
+ timeout-minutes : 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh.
118
+
119
+ steps :
120
+ - name : Download digests
121
+ uses : actions/download-artifact@v4
122
+ with :
123
+ path : ${{ runner.temp }}/digests
124
+ pattern : digests-*
125
+ merge-multiple : true
38
126
39
127
- name : Set up Docker Buildx
40
128
uses : docker/setup-buildx-action@v3
@@ -87,16 +175,14 @@ jobs:
87
175
org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
88
176
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
89
177
90
- - name : Build and push Docker image
91
- uses : docker/build-push-action@v6
92
- with :
93
- context : tools/docker
94
- platforms : linux/amd64,linux/arm64
95
- push : true
96
- tags : ${{ steps.meta.outputs.tags }}
97
- labels : ${{ steps.meta.outputs.labels }}
98
- 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 }}
178
+ - name : Create manifest list and push
179
+ working-directory : ${{ runner.temp }}/digests
180
+ run : |
181
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
182
+ $(printf "$REGISTRY_IMAGE@sha256:%s " *)
183
+
184
+ - name : Inspect image
185
+ env :
186
+ VERSION : ${{ steps.meta.outputs.version }}
187
+ run : |
188
+ docker buildx imagetools inspect "$REGISTRY_IMAGE:$VERSION"
0 commit comments