11name : Envoy/build-tools
2-
32permissions :
43 contents : read
5-
64on :
75 push :
86 branches :
97 - main
108 pull_request :
119
12-
1310jobs :
14- build_image :
11+ detect-changes :
12+ runs-on : ubuntu-latest
13+ if : >-
14+ github.repository == 'envoyproxy/envoy-build-tools'
15+ || vars.ENVOY_CI_RUN == 'true'
16+ outputs :
17+ debian : ${{ steps.set-outputs.outputs.debian }}
18+ ubuntu : ${{ steps.set-outputs.outputs.ubuntu }}
19+ steps :
20+ - uses : actions/checkout@v5
21+ with :
22+ fetch-depth : 0
23+ - uses : envoyproxy/toolshed/gh-actions/bson@actions-v0.3.30
24+ id : changed
25+ with :
26+ input : |
27+ base_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || 'HEAD^1' }}
28+ input-format : yaml
29+ filter : |
30+ .base_ref as $base_ref
31+ | "OUTPUT=$(git diff --name-only \($base_ref) HEAD)"
32+ | bash::output
33+ result-filter : |
34+ . | split("\n") | map(select(length > 0))
35+ - uses : envoyproxy/toolshed/gh-actions/jq@actions-v0.3.30
36+ id : config
37+ with :
38+ input : .github/config.yml
39+ input-format : yaml-path
40+ filter : |
41+ .
42+ - uses : envoyproxy/toolshed/gh-actions/torun@actions-v0.3.30
43+ id : torun
44+ with :
45+ event : ${{ github.event_name }}
46+ paths : ${{ steps.changed.outputs.output }}
47+ config : ${{ steps.config.outputs.value }}
48+ - id : set-outputs
49+ shell : bash
50+ run : |
51+ echo "debian=$(echo '${{ steps.torun.outputs.runs }}' | jq -r '.debian')" >> $GITHUB_OUTPUT
52+ echo "ubuntu=$(echo '${{ steps.torun.outputs.runs }}' | jq -r '.ubuntu')" >> $GITHUB_OUTPUT
53+
54+ build_image_debian :
55+ needs : detect-changes
56+ if : >-
57+ (github.repository == 'envoyproxy/envoy-build-tools' || vars.ENVOY_CI_RUN == 'true')
58+ && (github.event_name == 'push' || needs.detect-changes.outputs.debian == 'true')
59+ strategy :
60+ fail-fast : false
61+ matrix :
62+ arch :
63+ - amd64
64+ - arm64
65+ name : Build (debian-${{ matrix.arch }})
66+ uses : ./.github/workflows/_build_image.yml
67+ with :
68+ distro : debian
69+ host-platform : ${{ matrix.arch }}
70+ runs-on : ${{ matrix.arch == 'amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
71+ target-platforms : ${{ matrix.arch == 'amd64' && 'linux/amd64' || 'linux/arm64' }}
72+
73+ build_image_ubuntu :
74+ needs : detect-changes
1575 if : >-
16- ${{
17- github.repository == 'envoyproxy/envoy-build-tools'
18- || vars.ENVOY_CI_RUN == 'true'
19- }}
76+ (github.repository == 'envoyproxy/envoy-build-tools' || vars.ENVOY_CI_RUN == 'true')
77+ && (github.event_name == 'push' || needs.detect-changes.outputs.ubuntu == 'true')
2078 strategy :
2179 fail-fast : false
2280 matrix :
23- target : [ubuntu, debian]
24- arch : [amd64, arm64]
25- name : Build (${{ matrix.target }}-${{ matrix.arch }})
81+ arch :
82+ - amd64
83+ - arm64
84+ name : Build (ubuntu-${{ matrix.arch }})
2685 uses : ./.github/workflows/_build_image.yml
2786 with :
28- distro : ${{ matrix.target }}
29- os_family : ${{ matrix.os_family != '' && matrix.os_family || 'linux' }}
87+ distro : ubuntu
3088 host-platform : ${{ matrix.arch }}
3189 runs-on : ${{ matrix.arch == 'amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
3290 target-platforms : ${{ matrix.arch == 'amd64' && 'linux/amd64' || 'linux/arm64' }}
3391
3492 push-manifests :
3593 name : Create manifests (${{ github.event_name == 'pull_request' && 'dry run' || 'push' }})
3694 runs-on : ubuntu-latest
37- needs : [build_image]
95+ needs :
96+ - detect-changes
97+ - build_image_debian
98+ - build_image_ubuntu
99+ if : >-
100+ always()
101+ && (contains(fromJSON('["success", "skipped"]'), needs.build_image_debian.result)
102+ || contains(fromJSON('["success", "skipped"]'), needs.build_image_ubuntu.result))
38103 permissions :
39104 contents : read
40105 packages : write
@@ -56,118 +121,122 @@ jobs:
56121 run : |
57122 TAG_SHA=$(git log -1 --pretty=format:"%H" ./docker)
58123 echo "sha=${TAG_SHA}" >> $GITHUB_OUTPUT
59- - name : Generate manifest configuration
60- id : config
124+ - name : Determine which distros were built
125+ id : built-distros
126+ shell : bash
127+ run : |
128+ if [ "${{ github.event_name }}" = "push" ]; then
129+ echo "include-debian=true" >> $GITHUB_OUTPUT
130+ echo "include-ubuntu=true" >> $GITHUB_OUTPUT
131+ else
132+ echo "include-debian=${{ needs.build_image_debian.result == 'success' }}" >> $GITHUB_OUTPUT
133+ echo "include-ubuntu=${{ needs.build_image_ubuntu.result == 'success' }}" >> $GITHUB_OUTPUT
134+ fi
135+ - name : Generate manifest configuration (Debian)
136+ if : steps.built-distros.outputs.include-debian == 'true'
137+ id : config-debian
61138 uses : envoyproxy/toolshed/gh-actions/jq@actions-v0.3.26
62139 with :
63140 input-format : yaml
64141 filter : >-
65142 {manifests: .}
66143 input : |
67- ## debian
68- # devtools
69144 - name: envoy-build
70145 tag: devtools-${{ steps.docker-sha.outputs.sha }}
71146 registry: docker.io/envoyproxy
72147 architectures:
73148 - amd64
74149 - arm64
75150 artifact-pattern: oci-debian-{arch}/debian-devtools-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
76- # ci
77151 - name: envoy-build
78152 tag: ci-${{ steps.docker-sha.outputs.sha }}
79153 registry: docker.io/envoyproxy
80154 architectures:
81155 - amd64
82156 - arm64
83157 artifact-pattern: oci-debian-{arch}/debian-ci-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
84- # worker
85158 - name: envoy-build
86159 tag: worker-${{ steps.docker-sha.outputs.sha }}
87160 registry: docker.io/envoyproxy
88161 architectures:
89162 - amd64
90163 - arm64
91164 artifact-pattern: oci-debian-{arch}/debian-worker-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
92- # worker (gcr)
93165 - name: envoy-build
94166 tag: worker-${{ steps.docker-sha.outputs.sha }}
95167 registry: gcr.io/envoy-ci
96168 architectures:
97169 - amd64
98170 - arm64
99171 artifact-pattern: oci-debian-{arch}/debian-worker-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
100- # gcc
101172 - name: envoy-build
102173 tag: gcc-${{ steps.docker-sha.outputs.sha }}
103174 registry: docker.io/envoyproxy
104175 architectures:
105176 - amd64
106177 - arm64
107178 artifact-pattern: oci-debian-{arch}/debian-gcc-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
108- # gcc (gcr)
109179 - name: envoy-build
110180 tag: gcc-${{ steps.docker-sha.outputs.sha }}
111181 registry: gcr.io/envoy-ci
112182 architectures:
113183 - amd64
114184 - arm64
115185 artifact-pattern: oci-debian-{arch}/debian-gcc-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
116- # docker
117186 - name: envoy-build
118187 tag: docker-${{ steps.docker-sha.outputs.sha }}
119188 registry: docker.io/envoyproxy
120189 architectures:
121190 - amd64
122191 - arm64
123192 artifact-pattern: oci-debian-{arch}/debian-docker-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
124- # test
125193 - name: envoy-build
126194 tag: test-${{ steps.docker-sha.outputs.sha }}
127195 registry: docker.io/envoyproxy
128196 architectures:
129197 - amd64
130198 - arm64
131199 artifact-pattern: oci-debian-{arch}/debian-test-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
132- # llvm
133200 - name: envoy-build
134201 tag: llvm-${{ steps.docker-sha.outputs.sha }}
135202 registry: docker.io/envoyproxy
136203 architectures:
137204 - amd64
138205 artifact-pattern: oci-debian-{arch}/debian-llvm-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
139- # mobile
140206 - name: envoy-build
141207 tag: mobile-${{ steps.docker-sha.outputs.sha }}
142208 registry: docker.io/envoyproxy
143209 architectures:
144210 - amd64
145211 artifact-pattern: oci-debian-{arch}/debian-mobile-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
146-
147- ## ubuntu
148- # ci
212+ - name : Generate manifest configuration (Ubuntu)
213+ if : steps.built-distros.outputs.include-ubuntu == 'true'
214+ id : config-ubuntu
215+ uses : envoyproxy/toolshed/gh-actions/jq@actions-v0.3.26
216+ with :
217+ input-format : yaml
218+ filter : >-
219+ {manifests: .}
220+ input : |
149221 - name: envoy-build-ubuntu
150222 tag: ci-${{ steps.docker-sha.outputs.sha }}
151223 registry: docker.io/envoyproxy
152224 architectures:
153225 - arm64
154226 - amd64
155227 artifact-pattern: oci-ubuntu-{arch}/ubuntu-ci-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
156- # mobile
157228 - name: envoy-build-ubuntu
158229 tag: mobile-${{ steps.docker-sha.outputs.sha }}
159230 registry: docker.io/envoyproxy
160231 architectures:
161232 - amd64
162233 artifact-pattern: oci-ubuntu-{arch}/ubuntu-mobile-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
163- # test
164234 - name: envoy-build-ubuntu
165235 tag: test-${{ steps.docker-sha.outputs.sha }}
166236 registry: docker.io/envoyproxy
167237 architectures:
168238 - amd64
169239 artifact-pattern: oci-ubuntu-{arch}/ubuntu-test-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
170- # full
171240 - name: envoy-build-ubuntu
172241 tag: full-f8d1fd9bdac3a7843d1e69816456648989d238be
173242 registry: docker.io/envoyproxy
@@ -177,16 +246,39 @@ jobs:
177246 artifact-pattern: oci-ubuntu-{arch}/ubuntu-full-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
178247 additional-tags:
179248 - ${{ steps.docker-sha.outputs.sha }}
180- # full (gcr)
181249 - name: envoy-build
182250 tag: ${{ steps.docker-sha.outputs.sha }}
183251 registry: gcr.io/envoy-ci
184252 architectures:
185253 - amd64
186254 - arm64
187255 artifact-pattern: oci-ubuntu-{arch}/ubuntu-full-${{ steps.docker-sha.outputs.sha }}-{arch}.tar
256+ - name : Merge manifest configurations
257+ id : config
258+ if : >-
259+ steps.built-distros.outputs.include-debian == 'true'
260+ || steps.built-distros.outputs.include-ubuntu == 'true'
261+ shell : bash
262+ run : |
263+ DEBIAN_CONFIG='${{ steps.config-debian.outputs.value }}'
264+ UBUNTU_CONFIG='${{ steps.config-ubuntu.outputs.value }}'
265+ if [ "${{ steps.built-distros.outputs.include-debian }}" = "true" ] && [ "${{ steps.built-distros.outputs.include-ubuntu }}" = "true" ]; then
266+ MERGED=$(echo "$DEBIAN_CONFIG" "$UBUNTU_CONFIG" | jq -s '{"manifests": (.[0].manifests + .[1].manifests)}')
267+ elif [ "${{ steps.built-distros.outputs.include-debian }}" = "true" ]; then
268+ MERGED="$DEBIAN_CONFIG"
269+ elif [ "${{ steps.built-distros.outputs.include-ubuntu }}" = "true" ]; then
270+ MERGED="$UBUNTU_CONFIG"
271+ else
272+ MERGED='{"manifests": []}'
273+ fi
274+ echo "value<<EOF" >> $GITHUB_OUTPUT
275+ echo "$MERGED" >> $GITHUB_OUTPUT
276+ echo "EOF" >> $GITHUB_OUTPUT
188277 - name : Collect and push OCI artifacts
189278 uses : envoyproxy/toolshed/gh-actions/oci/collector@actions-v0.3.26
279+ if : >-
280+ steps.built-distros.outputs.include-debian == 'true'
281+ || steps.built-distros.outputs.include-ubuntu == 'true'
190282 with :
191283 manifest-config : ${{ steps.config.outputs.value }}
192284 dry-run : ${{ github.event_name == 'pull_request' }}
0 commit comments