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-images
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+ RELEASE=$(basename "${RELEASE_DIR}")
45+ echo "::group::${RELEASE}"
46+ bash .github/scripts/update-packages.sh "${RELEASE_DIR%/}"
47+ echo '::endgroup::'
48+ done
3149 - name : Gather info
3250 id : info
3351 run : |
@@ -46,16 +64,40 @@ jobs:
4664 commit-message : ${{steps.info.outputs.title}}
4765 author : ${{steps.info.outputs.commit-author}}
4866 committer : ${{steps.info.outputs.commit-author}}
49- add-paths : packages/generated/install.txt
67+ add-paths : releases/*/ packages/generated/install.txt
5068 base : ${{github.event.pull_request.head.ref}}
5169 branch : auto/update-packages/pr-${{github.event.pull_request.number}}
5270 delete-branch : true
5371 draft : true
5472 title : ${{steps.info.outputs.title}}
55- body : ${{steps. updates.outputs.update-body}}
73+ body : Automated package updates.
5674 labels : |
5775 dependencies
5876 auto
77+ check-base-images :
78+ name : Check Base Images
79+ runs-on : ubuntu-latest
80+ timeout-minutes : 5
81+ needs : determine-releases
82+ steps :
83+ - name : Checkout
84+ uses : actions/checkout@v6.0.2
85+ - name : Verify base images match releases
86+ run : |
87+ for RELEASE_DIR in releases/*/; do
88+ RELEASE=$(basename "${RELEASE_DIR}")
89+ echo "::group::${RELEASE}"
90+ FROM_LINE=$(grep -E '^FROM ubuntu:' "${RELEASE_DIR}Dockerfile")
91+ IMAGE_TAG=${FROM_LINE#FROM ubuntu:}
92+ IMAGE_STREAM=${IMAGE_TAG%%-*}
93+ if [[ "${IMAGE_STREAM}" != "${RELEASE}" ]]; then
94+ echo "::error::Base image '${FROM_LINE}' does not match" \
95+ "release '${RELEASE}' (expected 'FROM ubuntu:${RELEASE}-...')"
96+ exit 1
97+ fi
98+ echo "Base image '${FROM_LINE}' matches release '${RELEASE}'"
99+ echo '::endgroup::'
100+ done
59101 check-formatting-all :
60102 name : Check Formatting (All)
61103 runs-on : ubuntu-latest
76118 uses : actions/checkout@v6.0.2
77119 - name : Check formatting
78120 uses : hadolint/hadolint-action@v3.3.0
121+ with :
122+ recursive : true
79123 check-formatting-markdown :
80124 name : Check Formatting (Markdown)
81125 runs-on : ubuntu-latest
@@ -95,29 +139,28 @@ jobs:
95139 contents : read
96140 pull-requests : write
97141 needs :
142+ - determine-releases
143+ - check-base-images
98144 - check-packages
145+ strategy :
146+ fail-fast : false
147+ matrix :
148+ release : ${{fromJson(needs.determine-releases.outputs.releases)}}
99149 steps :
100150 - name : Checkout
101151 uses : actions/checkout@v6.0.2
102152 - name : Determine info
103153 id : info
104154 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"
155+ RELEASE_DIR="releases/${RELEASE}"
156+ PLATFORMS=$(paste -sd, "${RELEASE_DIR}/platforms.txt")
117157 TEMP_IMAGE='ci'
118158 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
159+ echo "ci-image-tag=$TEMP_IMAGE:${RELEASE}" >> $GITHUB_OUTPUT
160+ echo "ci-test-image-tag=$TEMP_IMAGE:${RELEASE}-test" >> $GITHUB_OUTPUT
161+ echo "release-dir=${RELEASE_DIR}" >> $GITHUB_OUTPUT
162+ env :
163+ RELEASE : ${{matrix.release}}
121164 - name : Set up Docker
122165 uses : docker/setup-docker-action@v5.0.0
123166 with :
@@ -130,22 +173,22 @@ jobs:
130173 - name : Build image
131174 uses : docker/build-push-action@v7.0.0
132175 with :
133- context : .
176+ context : ./${{steps.info.outputs.release-dir}}
134177 platforms : ${{steps.info.outputs.platforms}}
135178 tags : ${{steps.info.outputs.ci-image-tag}}
136- cache-from : type=gha
137- cache-to : type=gha,mode=max
179+ cache-from : type=gha,scope=${{matrix.release}}
180+ cache-to : type=gha,scope=${{matrix.release}}, mode=max
138181 load : true
139182 - name : Build test image
140183 uses : docker/build-push-action@v7.0.0
141184 with :
142- context : ./test
185+ context : ./${{steps.info.outputs.release-dir}}/ test
143186 build-contexts : |
144187 ci:image=docker-image://${{steps.info.outputs.ci-image-tag}}
145188 platforms : ${{steps.info.outputs.platforms}}
146189 tags : ${{steps.info.outputs.ci-test-image-tag}}
147- cache-from : type=gha
148- cache-to : type=gha,mode=max
190+ cache-from : type=gha,scope=${{matrix.release}}-test
191+ cache-to : type=gha,scope=${{matrix.release}}-test, mode=max
149192 load : true
150193 - name : Run tests
151194 run : >
@@ -164,13 +207,13 @@ jobs:
164207 - name : Hide outdated build details comments
165208 uses : int128/hide-comment-action@v1.53.0
166209 with :
167- starts-with : <!-- build details -->
210+ starts-with : <!-- build details (${{matrix.release}}) -->
168211 - name : Create build details comment
169212 id : image-details
170213 run : |
171214 # Determine the remote image tag to compare against
172215 echo "::group::Determine remote image tag"
173- VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' Dockerfile)
216+ VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' releases/${RELEASE}/ Dockerfile)
174217 VERSION=${VERSION##*:}
175218 STREAM=${VERSION%-*}
176219 REMOTE_IMAGE_TAG=$REMOTE_IMAGE:$STREAM
@@ -185,7 +228,7 @@ jobs:
185228 fi
186229 echo "::endgroup::"
187230 # Build the comment body per platform
188- BODY=$' <!-- build details -->\n\n'
231+ BODY=" <!-- build details (${RELEASE}) -->"$' \n\n'
189232 HAVE_REMOTE=true
190233 FAILED_PLATFORMS=()
191234 TOTAL_SIZE_NEW=0
@@ -269,7 +312,7 @@ jobs:
269312 elif (( OVERALL_DIFF < 0 )); then
270313 OVERALL_SIZE+=" \`$(echo $OVERALL_DIFF | numfmt $FMT)\`"
271314 fi
272- BODY+=$' ## Build Details\n\n'
315+ BODY+=" ## Build Details (${RELEASE})"$' \n\n'
273316 if [[ "$HAVE_REMOTE" != "true" ]]; then
274317 BODY+=$'> [!WARNING]\n'
275318 BODY+=$'> Size comparison may be inaccurate.'
@@ -287,6 +330,7 @@ jobs:
287330 echo "::endgroup::"
288331 gh pr comment "$PULL_REQUEST_NUMBER" --body "$BODY"
289332 env :
333+ RELEASE : ${{matrix.release}}
290334 REMOTE_IMAGE : ghcr.io/${{github.repository_owner}}/base-ubuntu
291335 LOCAL_IMAGE_TAG : ${{steps.info.outputs.ci-image-tag}}
292336 PLATFORMS : ${{steps.info.outputs.platforms}}
0 commit comments