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 :
1612 check-packages :
@@ -20,23 +16,34 @@ jobs:
2016 permissions :
2117 contents : write
2218 pull-requests : write
19+ needs : check-base-image
20+ strategy :
21+ fail-fast : false
22+ matrix :
23+ release :
24+ - noble
25+ - jammy
26+ - focal
2327 steps :
2428 - name : Checkout
2529 uses : actions/checkout@v6.0.2
2630 with :
2731 ref : ${{github.head_ref}}
2832 - name : Update packages
2933 id : updates
30- run : bash .github/scripts/update-packages.sh
34+ run : bash .github/scripts/update-packages.sh releases/${RELEASE}
35+ env :
36+ RELEASE : ${{matrix.release}}
3137 - name : Gather info
3238 id : info
3339 run : |
3440 USER_NAME="github-actions[bot]"
3541 USER_ID=$(gh api "/users/${USER_NAME}" --jq '.id')
3642 USER_EMAIL="${USER_ID}+${USER_NAME}@users.noreply.github.com"
3743 echo "commit-author=${USER_NAME} <${USER_EMAIL}>" >> "${GITHUB_OUTPUT}"
38- echo "title=Update packages for PR #${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
44+ echo "title=Update packages (${RELEASE}) for PR #${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
3945 env :
46+ RELEASE : ${{matrix.release}}
4047 GITHUB_TOKEN : ${{github.token}}
4148 PR_NUMBER : ${{github.event.pull_request.number}}
4249 - name : Push changes
@@ -46,16 +53,43 @@ jobs:
4653 commit-message : ${{steps.info.outputs.title}}
4754 author : ${{steps.info.outputs.commit-author}}
4855 committer : ${{steps.info.outputs.commit-author}}
49- add-paths : packages/generated/install.txt
56+ add-paths : releases/${{matrix.release}}/ packages/generated/install.txt
5057 base : ${{github.event.pull_request.head.ref}}
51- branch : auto/update-packages/pr-${{github.event.pull_request.number}}
58+ branch : auto/update-packages/${{matrix.release}}/ pr-${{github.event.pull_request.number}}
5259 delete-branch : true
5360 draft : true
5461 title : ${{steps.info.outputs.title}}
5562 body : ${{steps.updates.outputs.update-body}}
5663 labels : |
5764 dependencies
5865 auto
66+ check-base-image :
67+ name : Check Base Image
68+ runs-on : ubuntu-latest
69+ timeout-minutes : 5
70+ strategy :
71+ fail-fast : false
72+ matrix :
73+ release :
74+ - noble
75+ - jammy
76+ - focal
77+ steps :
78+ - name : Checkout
79+ uses : actions/checkout@v6.0.2
80+ - name : Verify base image matches release
81+ run : |
82+ FROM_LINE=$(grep -E '^FROM ubuntu:' "releases/${RELEASE}/Dockerfile")
83+ IMAGE_TAG=${FROM_LINE#FROM ubuntu:}
84+ IMAGE_STREAM=${IMAGE_TAG%%-*}
85+ if [[ "${IMAGE_STREAM}" != "${RELEASE}" ]]; then
86+ echo "::error::Base image '${FROM_LINE}' does not match" \
87+ "release '${RELEASE}' (expected 'FROM ubuntu:${RELEASE}-...')"
88+ exit 1
89+ fi
90+ echo "Base image '${FROM_LINE}' matches release '${RELEASE}'"
91+ env :
92+ RELEASE : ${{matrix.release}}
5993 check-formatting-all :
6094 name : Check Formatting (All)
6195 runs-on : ubuntu-latest
76110 uses : actions/checkout@v6.0.2
77111 - name : Check formatting
78112 uses : hadolint/hadolint-action@v3.3.0
113+ with :
114+ recursive : true
79115 check-formatting-markdown :
80116 name : Check Formatting (Markdown)
81117 runs-on : ubuntu-latest
@@ -94,30 +130,29 @@ jobs:
94130 permissions :
95131 contents : read
96132 pull-requests : write
97- needs :
98- - check-packages
133+ needs : check-packages
134+ strategy :
135+ fail-fast : false
136+ matrix :
137+ release :
138+ - noble
139+ - jammy
140+ - focal
99141 steps :
100142 - name : Checkout
101143 uses : actions/checkout@v6.0.2
102144 - name : Determine info
103145 id : info
104146 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"
147+ RELEASE_DIR="releases/${RELEASE}"
148+ PLATFORMS=$(paste -sd, "${RELEASE_DIR}/platforms.txt")
117149 TEMP_IMAGE='ci'
118150 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
151+ echo "ci-image-tag=$TEMP_IMAGE:${RELEASE}" >> $GITHUB_OUTPUT
152+ echo "ci-test-image-tag=$TEMP_IMAGE:${RELEASE}-test" >> $GITHUB_OUTPUT
153+ echo "release-dir=${RELEASE_DIR}" >> $GITHUB_OUTPUT
154+ env :
155+ RELEASE : ${{matrix.release}}
121156 - name : Set up Docker
122157 uses : docker/setup-docker-action@v5.0.0
123158 with :
@@ -130,22 +165,22 @@ jobs:
130165 - name : Build image
131166 uses : docker/build-push-action@v7.0.0
132167 with :
133- context : .
168+ context : ./${{steps.info.outputs.release-dir}}
134169 platforms : ${{steps.info.outputs.platforms}}
135170 tags : ${{steps.info.outputs.ci-image-tag}}
136- cache-from : type=gha
137- cache-to : type=gha,mode=max
171+ cache-from : type=gha,scope=${{matrix.release}}
172+ cache-to : type=gha,scope=${{matrix.release}}, mode=max
138173 load : true
139174 - name : Build test image
140175 uses : docker/build-push-action@v7.0.0
141176 with :
142- context : ./test
177+ context : ./${{steps.info.outputs.release-dir}}/ test
143178 build-contexts : |
144179 ci:image=docker-image://${{steps.info.outputs.ci-image-tag}}
145180 platforms : ${{steps.info.outputs.platforms}}
146181 tags : ${{steps.info.outputs.ci-test-image-tag}}
147- cache-from : type=gha
148- cache-to : type=gha,mode=max
182+ cache-from : type=gha,scope=${{matrix.release}}-test
183+ cache-to : type=gha,scope=${{matrix.release}}-test, mode=max
149184 load : true
150185 - name : Run tests
151186 run : >
@@ -164,13 +199,13 @@ jobs:
164199 - name : Hide outdated build details comments
165200 uses : int128/hide-comment-action@v1.53.0
166201 with :
167- starts-with : <!-- build details -->
202+ starts-with : <!-- build details (${{matrix.release}}) -->
168203 - name : Create build details comment
169204 id : image-details
170205 run : |
171206 # Determine the remote image tag to compare against
172207 echo "::group::Determine remote image tag"
173- VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' Dockerfile)
208+ VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' releases/${RELEASE}/ Dockerfile)
174209 VERSION=${VERSION##*:}
175210 STREAM=${VERSION%-*}
176211 REMOTE_IMAGE_TAG=$REMOTE_IMAGE:$STREAM
@@ -185,7 +220,7 @@ jobs:
185220 fi
186221 echo "::endgroup::"
187222 # Build the comment body per platform
188- BODY=$'<!-- build details -->\n\n'
223+ BODY=$'<!-- build details (${RELEASE}) -->\n\n'
189224 HAVE_REMOTE=true
190225 FAILED_PLATFORMS=()
191226 TOTAL_SIZE_NEW=0
@@ -269,7 +304,7 @@ jobs:
269304 elif (( OVERALL_DIFF < 0 )); then
270305 OVERALL_SIZE+=" \`$(echo $OVERALL_DIFF | numfmt $FMT)\`"
271306 fi
272- BODY+=$'## Build Details\n\n'
307+ BODY+=$'## Build Details (${RELEASE}) \n\n'
273308 if [[ "$HAVE_REMOTE" != "true" ]]; then
274309 BODY+=$'> [!WARNING]\n'
275310 BODY+=$'> Size comparison may be inaccurate.'
@@ -287,6 +322,7 @@ jobs:
287322 echo "::endgroup::"
288323 gh pr comment "$PULL_REQUEST_NUMBER" --body "$BODY"
289324 env :
325+ RELEASE : ${{matrix.release}}
290326 REMOTE_IMAGE : ghcr.io/${{github.repository_owner}}/base-ubuntu
291327 LOCAL_IMAGE_TAG : ${{steps.info.outputs.ci-image-tag}}
292328 PLATFORMS : ${{steps.info.outputs.platforms}}
0 commit comments