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)
25+ echo "Releases: ${RELEASES//$'\n'/, }"
26+ RELEASES=$(echo "$RELEASES" | jq -Rnc '[inputs]')
27+ echo "releases=${RELEASES}" >> "${GITHUB_OUTPUT}"
1628 check-packages :
1729 name : Check Packages
1830 runs-on : ubuntu-latest
1931 timeout-minutes : 10
2032 permissions :
2133 contents : write
2234 pull-requests : write
35+ needs :
36+ - determine-releases
37+ - check-base-images
2338 steps :
2439 - name : Checkout
2540 uses : actions/checkout@v6.0.2
2641 with :
2742 ref : ${{github.head_ref}}
2843 - name : Update packages
29- id : updates
30- run : bash .github/scripts/update-packages.sh
44+ run : |
45+ for RELEASE_DIR in releases/*/; do
46+ RELEASE=$(basename "${RELEASE_DIR}")
47+ echo "::group::${RELEASE}"
48+ bash .github/scripts/update-packages.sh "${RELEASE_DIR%/}"
49+ echo '::endgroup::'
50+ done
3151 - name : Gather info
3252 id : info
3353 run : |
@@ -46,16 +66,40 @@ jobs:
4666 commit-message : ${{steps.info.outputs.title}}
4767 author : ${{steps.info.outputs.commit-author}}
4868 committer : ${{steps.info.outputs.commit-author}}
49- add-paths : packages/generated/install.txt
69+ add-paths : releases/*/ packages/generated/install.txt
5070 base : ${{github.event.pull_request.head.ref}}
5171 branch : auto/update-packages/pr-${{github.event.pull_request.number}}
5272 delete-branch : true
5373 draft : true
5474 title : ${{steps.info.outputs.title}}
55- body : ${{steps. updates.outputs.update-body}}
75+ body : Automated package updates.
5676 labels : |
5777 dependencies
5878 auto
79+ check-base-images :
80+ name : Check Base Images
81+ runs-on : ubuntu-latest
82+ timeout-minutes : 5
83+ needs : determine-releases
84+ steps :
85+ - name : Checkout
86+ uses : actions/checkout@v6.0.2
87+ - name : Verify base images match releases
88+ run : |
89+ for RELEASE_DIR in releases/*/; do
90+ RELEASE=$(basename "${RELEASE_DIR}")
91+ echo "::group::${RELEASE}"
92+ FROM_LINE=$(grep -E '^FROM ubuntu:' "${RELEASE_DIR}Dockerfile")
93+ IMAGE_TAG=${FROM_LINE#FROM ubuntu:}
94+ IMAGE_STREAM=${IMAGE_TAG%%-*}
95+ if [[ "${IMAGE_STREAM}" != "${RELEASE}" ]]; then
96+ echo "::error::Base image '${FROM_LINE}' does not match" \
97+ "release '${RELEASE}' (expected 'FROM ubuntu:${RELEASE}-...')"
98+ exit 1
99+ fi
100+ echo "Base image '${FROM_LINE}' matches release '${RELEASE}'"
101+ echo '::endgroup::'
102+ done
59103 check-formatting-all :
60104 name : Check Formatting (All)
61105 runs-on : ubuntu-latest
76120 uses : actions/checkout@v6.0.2
77121 - name : Check formatting
78122 uses : hadolint/hadolint-action@v3.3.0
123+ with :
124+ recursive : true
79125 check-formatting-markdown :
80126 name : Check Formatting (Markdown)
81127 runs-on : ubuntu-latest
@@ -95,29 +141,28 @@ jobs:
95141 contents : read
96142 pull-requests : write
97143 needs :
144+ - determine-releases
145+ - check-base-images
98146 - check-packages
147+ strategy :
148+ fail-fast : false
149+ matrix :
150+ release : ${{fromJson(needs.determine-releases.outputs.releases)}}
99151 steps :
100152 - name : Checkout
101153 uses : actions/checkout@v6.0.2
102154 - name : Determine info
103155 id : info
104156 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"
157+ RELEASE_DIR="releases/${RELEASE}"
158+ PLATFORMS=$(paste -sd, "${RELEASE_DIR}/platforms.txt")
117159 TEMP_IMAGE='ci'
118160 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
161+ echo "ci-image-tag=$TEMP_IMAGE:${RELEASE}" >> $GITHUB_OUTPUT
162+ echo "ci-test-image-tag=$TEMP_IMAGE:${RELEASE}-test" >> $GITHUB_OUTPUT
163+ echo "release-dir=${RELEASE_DIR}" >> $GITHUB_OUTPUT
164+ env :
165+ RELEASE : ${{matrix.release}}
121166 - name : Set up Docker
122167 uses : docker/setup-docker-action@v5.0.0
123168 with :
@@ -130,22 +175,22 @@ jobs:
130175 - name : Build image
131176 uses : docker/build-push-action@v7.0.0
132177 with :
133- context : .
178+ context : ./${{steps.info.outputs.release-dir}}
134179 platforms : ${{steps.info.outputs.platforms}}
135180 tags : ${{steps.info.outputs.ci-image-tag}}
136- cache-from : type=gha
137- cache-to : type=gha,mode=max
181+ cache-from : type=gha,scope=${{matrix.release}}
182+ cache-to : type=gha,scope=${{matrix.release}}, mode=max
138183 load : true
139184 - name : Build test image
140185 uses : docker/build-push-action@v7.0.0
141186 with :
142- context : ./test
187+ context : ./${{steps.info.outputs.release-dir}}/ test
143188 build-contexts : |
144189 ci:image=docker-image://${{steps.info.outputs.ci-image-tag}}
145190 platforms : ${{steps.info.outputs.platforms}}
146191 tags : ${{steps.info.outputs.ci-test-image-tag}}
147- cache-from : type=gha
148- cache-to : type=gha,mode=max
192+ cache-from : type=gha,scope=${{matrix.release}}-test
193+ cache-to : type=gha,scope=${{matrix.release}}-test, mode=max
149194 load : true
150195 - name : Run tests
151196 run : >
@@ -164,13 +209,13 @@ jobs:
164209 - name : Hide outdated build details comments
165210 uses : int128/hide-comment-action@v1.53.0
166211 with :
167- starts-with : <!-- build details -->
212+ starts-with : <!-- build details (${{matrix.release}}) -->
168213 - name : Create build details comment
169214 id : image-details
170215 run : |
171216 # Determine the remote image tag to compare against
172217 echo "::group::Determine remote image tag"
173- VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' Dockerfile)
218+ VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' releases/${RELEASE}/ Dockerfile)
174219 VERSION=${VERSION##*:}
175220 STREAM=${VERSION%-*}
176221 REMOTE_IMAGE_TAG=$REMOTE_IMAGE:$STREAM
@@ -185,7 +230,7 @@ jobs:
185230 fi
186231 echo "::endgroup::"
187232 # Build the comment body per platform
188- BODY=$' <!-- build details -->\n\n'
233+ BODY=" <!-- build details (${RELEASE}) -->"$' \n\n'
189234 HAVE_REMOTE=true
190235 FAILED_PLATFORMS=()
191236 TOTAL_SIZE_NEW=0
@@ -269,7 +314,7 @@ jobs:
269314 elif (( OVERALL_DIFF < 0 )); then
270315 OVERALL_SIZE+=" \`$(echo $OVERALL_DIFF | numfmt $FMT)\`"
271316 fi
272- BODY+=$' ## Build Details\n\n'
317+ BODY+=" ## Build Details (${RELEASE})"$' \n\n'
273318 if [[ "$HAVE_REMOTE" != "true" ]]; then
274319 BODY+=$'> [!WARNING]\n'
275320 BODY+=$'> Size comparison may be inaccurate.'
@@ -287,6 +332,7 @@ jobs:
287332 echo "::endgroup::"
288333 gh pr comment "$PULL_REQUEST_NUMBER" --body "$BODY"
289334 env :
335+ RELEASE : ${{matrix.release}}
290336 REMOTE_IMAGE : ghcr.io/${{github.repository_owner}}/base-ubuntu
291337 LOCAL_IMAGE_TAG : ${{steps.info.outputs.ci-image-tag}}
292338 PLATFORMS : ${{steps.info.outputs.platforms}}
0 commit comments