11name : Pull Request
2- on :
3- pull_request :
4- branches :
5- - main
6- - release/*
2+ on : pull_request
73permissions :
84 contents : read
95defaults :
106 run :
117 shell : bash
128concurrency :
13- group : ${{github.event.pull_request.number }}
9+ group : ${{github.workflow_ref }}
1410 cancel-in-progress : true
1511jobs :
12+ determine-releases :
13+ name : Determine Releases
14+ runs-on : ubuntu-latest
15+ timeout-minutes : 5
16+ outputs :
17+ releases : ${{steps.releases.outputs.releases}}
18+ steps :
19+ - name : Checkout
20+ uses : actions/checkout@v6.0.2
21+ - name : Determine releases
22+ id : releases
23+ run : |
24+ RELEASES=$(ls -d releases/*/ | xargs -n1 basename | jq -Rnc '[inputs]')
25+ echo "releases=${RELEASES}" >> "${GITHUB_OUTPUT}"
1626 check-packages :
1727 name : Check Packages
1828 runs-on : ubuntu-latest
1929 timeout-minutes : 10
2030 permissions :
2131 contents : write
2232 pull-requests : write
33+ needs :
34+ - determine-releases
35+ - check-base-image
2336 steps :
2437 - name : Checkout
2538 uses : actions/checkout@v6.0.2
2639 with :
2740 ref : ${{github.head_ref}}
2841 - name : Update packages
29- id : updates
30- run : bash .github/scripts/update-packages.sh
42+ run : |
43+ for RELEASE_DIR in releases/*/; do
44+ bash .github/scripts/update-packages.sh "${RELEASE_DIR%/}"
45+ done
3146 - name : Gather info
3247 id : info
3348 run : |
@@ -46,16 +61,38 @@ jobs:
4661 commit-message : ${{steps.info.outputs.title}}
4762 author : ${{steps.info.outputs.commit-author}}
4863 committer : ${{steps.info.outputs.commit-author}}
49- add-paths : packages/generated/install.txt
64+ add-paths : releases/*/ packages/generated/install.txt
5065 base : ${{github.event.pull_request.head.ref}}
5166 branch : auto/update-packages/pr-${{github.event.pull_request.number}}
5267 delete-branch : true
5368 draft : true
5469 title : ${{steps.info.outputs.title}}
55- body : ${{steps. updates.outputs.update-body}}
70+ body : Automated package updates.
5671 labels : |
5772 dependencies
5873 auto
74+ check-base-image :
75+ name : Check Base Image
76+ runs-on : ubuntu-latest
77+ timeout-minutes : 5
78+ needs : determine-releases
79+ steps :
80+ - name : Checkout
81+ uses : actions/checkout@v6.0.2
82+ - name : Verify base images match releases
83+ run : |
84+ for RELEASE_DIR in releases/*/; do
85+ RELEASE=$(basename "${RELEASE_DIR}")
86+ FROM_LINE=$(grep -E '^FROM ubuntu:' "${RELEASE_DIR}Dockerfile")
87+ IMAGE_TAG=${FROM_LINE#FROM ubuntu:}
88+ IMAGE_STREAM=${IMAGE_TAG%%-*}
89+ if [[ "${IMAGE_STREAM}" != "${RELEASE}" ]]; then
90+ echo "::error::Base image '${FROM_LINE}' does not match" \
91+ "release '${RELEASE}' (expected 'FROM ubuntu:${RELEASE}-...')"
92+ exit 1
93+ fi
94+ echo "Base image '${FROM_LINE}' matches release '${RELEASE}'"
95+ done
5996 check-formatting-all :
6097 name : Check Formatting (All)
6198 runs-on : ubuntu-latest
76113 uses : actions/checkout@v6.0.2
77114 - name : Check formatting
78115 uses : hadolint/hadolint-action@v3.3.0
116+ with :
117+ recursive : true
79118 check-formatting-markdown :
80119 name : Check Formatting (Markdown)
81120 runs-on : ubuntu-latest
@@ -95,29 +134,28 @@ jobs:
95134 contents : read
96135 pull-requests : write
97136 needs :
137+ - determine-releases
138+ - check-base-image
98139 - check-packages
140+ strategy :
141+ fail-fast : false
142+ matrix :
143+ release : ${{fromJson(needs.determine-releases.outputs.releases)}}
99144 steps :
100145 - name : Checkout
101146 uses : actions/checkout@v6.0.2
102147 - name : Determine info
103148 id : info
104149 run : |
105- PLATFORMS=(
106- linux/amd64
107- linux/arm/v7
108- linux/arm64
109- linux/ppc64le
110- linux/riscv64
111- linux/s390x
112- )
113- SAVE_IFS="$IFS"
114- IFS=","
115- PLATFORMS="${PLATFORMS[*]}"
116- IFS="$SAVE_IFS"
150+ RELEASE_DIR="releases/${RELEASE}"
151+ PLATFORMS=$(paste -sd, "${RELEASE_DIR}/platforms.txt")
117152 TEMP_IMAGE='ci'
118153 echo "platforms=$PLATFORMS" >> $GITHUB_OUTPUT
119- echo "ci-image-tag=$TEMP_IMAGE:image" >> $GITHUB_OUTPUT
120- echo "ci-test-image-tag=$TEMP_IMAGE:test-image" >> $GITHUB_OUTPUT
154+ echo "ci-image-tag=$TEMP_IMAGE:${RELEASE}" >> $GITHUB_OUTPUT
155+ echo "ci-test-image-tag=$TEMP_IMAGE:${RELEASE}-test" >> $GITHUB_OUTPUT
156+ echo "release-dir=${RELEASE_DIR}" >> $GITHUB_OUTPUT
157+ env :
158+ RELEASE : ${{matrix.release}}
121159 - name : Set up Docker
122160 uses : docker/setup-docker-action@v5.0.0
123161 with :
@@ -130,22 +168,22 @@ jobs:
130168 - name : Build image
131169 uses : docker/build-push-action@v7.0.0
132170 with :
133- context : .
171+ context : ./${{steps.info.outputs.release-dir}}
134172 platforms : ${{steps.info.outputs.platforms}}
135173 tags : ${{steps.info.outputs.ci-image-tag}}
136- cache-from : type=gha
137- cache-to : type=gha,mode=max
174+ cache-from : type=gha,scope=${{matrix.release}}
175+ cache-to : type=gha,scope=${{matrix.release}}, mode=max
138176 load : true
139177 - name : Build test image
140178 uses : docker/build-push-action@v7.0.0
141179 with :
142- context : ./test
180+ context : ./${{steps.info.outputs.release-dir}}/ test
143181 build-contexts : |
144182 ci:image=docker-image://${{steps.info.outputs.ci-image-tag}}
145183 platforms : ${{steps.info.outputs.platforms}}
146184 tags : ${{steps.info.outputs.ci-test-image-tag}}
147- cache-from : type=gha
148- cache-to : type=gha,mode=max
185+ cache-from : type=gha,scope=${{matrix.release}}-test
186+ cache-to : type=gha,scope=${{matrix.release}}-test, mode=max
149187 load : true
150188 - name : Run tests
151189 run : >
@@ -164,13 +202,13 @@ jobs:
164202 - name : Hide outdated build details comments
165203 uses : int128/hide-comment-action@v1.53.0
166204 with :
167- starts-with : <!-- build details -->
205+ starts-with : <!-- build details (${{matrix.release}}) -->
168206 - name : Create build details comment
169207 id : image-details
170208 run : |
171209 # Determine the remote image tag to compare against
172210 echo "::group::Determine remote image tag"
173- VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' Dockerfile)
211+ VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' releases/${RELEASE}/ Dockerfile)
174212 VERSION=${VERSION##*:}
175213 STREAM=${VERSION%-*}
176214 REMOTE_IMAGE_TAG=$REMOTE_IMAGE:$STREAM
@@ -185,7 +223,7 @@ jobs:
185223 fi
186224 echo "::endgroup::"
187225 # Build the comment body per platform
188- BODY=$'<!-- build details -->\n\n'
226+ BODY=$'<!-- build details (${RELEASE}) -->\n\n'
189227 HAVE_REMOTE=true
190228 FAILED_PLATFORMS=()
191229 TOTAL_SIZE_NEW=0
@@ -269,7 +307,7 @@ jobs:
269307 elif (( OVERALL_DIFF < 0 )); then
270308 OVERALL_SIZE+=" \`$(echo $OVERALL_DIFF | numfmt $FMT)\`"
271309 fi
272- BODY+=$'## Build Details\n\n'
310+ BODY+=$'## Build Details (${RELEASE}) \n\n'
273311 if [[ "$HAVE_REMOTE" != "true" ]]; then
274312 BODY+=$'> [!WARNING]\n'
275313 BODY+=$'> Size comparison may be inaccurate.'
@@ -287,6 +325,7 @@ jobs:
287325 echo "::endgroup::"
288326 gh pr comment "$PULL_REQUEST_NUMBER" --body "$BODY"
289327 env :
328+ RELEASE : ${{matrix.release}}
290329 REMOTE_IMAGE : ghcr.io/${{github.repository_owner}}/base-ubuntu
291330 LOCAL_IMAGE_TAG : ${{steps.info.outputs.ci-image-tag}}
292331 PLATFORMS : ${{steps.info.outputs.platforms}}
0 commit comments