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,37 @@ jobs:
2016 permissions :
2117 contents : write
2218 pull-requests : write
19+ needs :
20+ - check-formatting-all
21+ - check-formatting-dockerfile
22+ - check-formatting-markdown
23+ strategy :
24+ fail-fast : false
25+ matrix :
26+ release :
27+ - noble
28+ - jammy
29+ - focal
2330 steps :
2431 - name : Checkout
2532 uses : actions/checkout@v6.0.2
2633 with :
2734 ref : ${{github.head_ref}}
2835 - name : Update packages
2936 id : updates
30- run : bash .github/scripts/update-packages.sh
37+ run : bash .github/scripts/update-packages.sh releases/${RELEASE}
38+ env :
39+ RELEASE : ${{matrix.release}}
3140 - name : Gather info
3241 id : info
3342 run : |
3443 USER_NAME="github-actions[bot]"
3544 USER_ID=$(gh api "/users/${USER_NAME}" --jq '.id')
3645 USER_EMAIL="${USER_ID}+${USER_NAME}@users.noreply.github.com"
3746 echo "commit-author=${USER_NAME} <${USER_EMAIL}>" >> "${GITHUB_OUTPUT}"
38- echo "title=Update packages for PR #${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
47+ echo "title=Update packages (${RELEASE}) for PR #${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
3948 env :
49+ RELEASE : ${{matrix.release}}
4050 GITHUB_TOKEN : ${{github.token}}
4151 PR_NUMBER : ${{github.event.pull_request.number}}
4252 - name : Push changes
@@ -46,16 +56,47 @@ jobs:
4656 commit-message : ${{steps.info.outputs.title}}
4757 author : ${{steps.info.outputs.commit-author}}
4858 committer : ${{steps.info.outputs.commit-author}}
49- add-paths : packages/generated/install.txt
59+ add-paths : releases/${{matrix.release}}/ packages/generated/install.txt
5060 base : ${{github.event.pull_request.head.ref}}
51- branch : auto/update-packages/pr-${{github.event.pull_request.number}}
61+ branch : auto/update-packages/${{matrix.release}}/ pr-${{github.event.pull_request.number}}
5262 delete-branch : true
5363 draft : true
5464 title : ${{steps.info.outputs.title}}
5565 body : ${{steps.updates.outputs.update-body}}
5666 labels : |
5767 dependencies
5868 auto
69+ check-base-image :
70+ name : Check Base Image
71+ runs-on : ubuntu-latest
72+ timeout-minutes : 5
73+ needs :
74+ - check-formatting-all
75+ - check-formatting-dockerfile
76+ - check-formatting-markdown
77+ strategy :
78+ fail-fast : false
79+ matrix :
80+ release :
81+ - noble
82+ - jammy
83+ - focal
84+ steps :
85+ - name : Checkout
86+ uses : actions/checkout@v6.0.2
87+ - name : Verify base image matches release
88+ run : |
89+ FROM_LINE=$(grep -E '^FROM ubuntu:' "releases/${RELEASE}/Dockerfile")
90+ IMAGE_TAG=${FROM_LINE#FROM ubuntu:}
91+ IMAGE_STREAM=${IMAGE_TAG%%-*}
92+ if [[ "${IMAGE_STREAM}" != "${RELEASE}" ]]; then
93+ echo "::error::Base image '${FROM_LINE}' does not match" \
94+ "release '${RELEASE}' (expected 'FROM ubuntu:${RELEASE}-...')"
95+ exit 1
96+ fi
97+ echo "Base image '${FROM_LINE}' matches release '${RELEASE}'"
98+ env :
99+ RELEASE : ${{matrix.release}}
59100 check-formatting-all :
60101 name : Check Formatting (All)
61102 runs-on : ubuntu-latest
76117 uses : actions/checkout@v6.0.2
77118 - name : Check formatting
78119 uses : hadolint/hadolint-action@v3.3.0
120+ with :
121+ recursive : true
79122 check-formatting-markdown :
80123 name : Check Formatting (Markdown)
81124 runs-on : ubuntu-latest
@@ -95,29 +138,30 @@ jobs:
95138 contents : read
96139 pull-requests : write
97140 needs :
141+ - check-base-image
98142 - check-packages
143+ strategy :
144+ fail-fast : false
145+ matrix :
146+ release :
147+ - noble
148+ - jammy
149+ - focal
99150 steps :
100151 - name : Checkout
101152 uses : actions/checkout@v6.0.2
102153 - name : Determine info
103154 id : info
104155 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"
156+ RELEASE_DIR="releases/${RELEASE}"
157+ PLATFORMS=$(paste -sd, "${RELEASE_DIR}/platforms.txt")
117158 TEMP_IMAGE='ci'
118159 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
160+ echo "ci-image-tag=$TEMP_IMAGE:${RELEASE}" >> $GITHUB_OUTPUT
161+ echo "ci-test-image-tag=$TEMP_IMAGE:${RELEASE}-test" >> $GITHUB_OUTPUT
162+ echo "release-dir=${RELEASE_DIR}" >> $GITHUB_OUTPUT
163+ env :
164+ RELEASE : ${{matrix.release}}
121165 - name : Set up Docker
122166 uses : docker/setup-docker-action@v5.0.0
123167 with :
@@ -130,22 +174,22 @@ jobs:
130174 - name : Build image
131175 uses : docker/build-push-action@v7.0.0
132176 with :
133- context : .
177+ context : ./${{steps.info.outputs.release-dir}}
134178 platforms : ${{steps.info.outputs.platforms}}
135179 tags : ${{steps.info.outputs.ci-image-tag}}
136- cache-from : type=gha
137- cache-to : type=gha,mode=max
180+ cache-from : type=gha,scope=${{matrix.release}}
181+ cache-to : type=gha,scope=${{matrix.release}}, mode=max
138182 load : true
139183 - name : Build test image
140184 uses : docker/build-push-action@v7.0.0
141185 with :
142- context : ./test
186+ context : ./${{steps.info.outputs.release-dir}}/ test
143187 build-contexts : |
144188 ci:image=docker-image://${{steps.info.outputs.ci-image-tag}}
145189 platforms : ${{steps.info.outputs.platforms}}
146190 tags : ${{steps.info.outputs.ci-test-image-tag}}
147- cache-from : type=gha
148- cache-to : type=gha,mode=max
191+ cache-from : type=gha,scope=${{matrix.release}}-test
192+ cache-to : type=gha,scope=${{matrix.release}}-test, mode=max
149193 load : true
150194 - name : Run tests
151195 run : >
@@ -164,13 +208,13 @@ jobs:
164208 - name : Hide outdated build details comments
165209 uses : int128/hide-comment-action@v1.53.0
166210 with :
167- starts-with : <!-- build details -->
211+ starts-with : <!-- build details (${{matrix.release}}) -->
168212 - name : Create build details comment
169213 id : image-details
170214 run : |
171215 # Determine the remote image tag to compare against
172216 echo "::group::Determine remote image tag"
173- VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' Dockerfile)
217+ VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' releases/${RELEASE}/ Dockerfile)
174218 VERSION=${VERSION##*:}
175219 STREAM=${VERSION%-*}
176220 REMOTE_IMAGE_TAG=$REMOTE_IMAGE:$STREAM
@@ -185,7 +229,7 @@ jobs:
185229 fi
186230 echo "::endgroup::"
187231 # Build the comment body per platform
188- BODY=$'<!-- build details -->\n\n'
232+ BODY=$'<!-- build details (${RELEASE}) -->\n\n'
189233 HAVE_REMOTE=true
190234 FAILED_PLATFORMS=()
191235 TOTAL_SIZE_NEW=0
@@ -269,7 +313,7 @@ jobs:
269313 elif (( OVERALL_DIFF < 0 )); then
270314 OVERALL_SIZE+=" \`$(echo $OVERALL_DIFF | numfmt $FMT)\`"
271315 fi
272- BODY+=$'## Build Details\n\n'
316+ BODY+=$'## Build Details (${RELEASE}) \n\n'
273317 if [[ "$HAVE_REMOTE" != "true" ]]; then
274318 BODY+=$'> [!WARNING]\n'
275319 BODY+=$'> Size comparison may be inaccurate.'
@@ -287,6 +331,7 @@ jobs:
287331 echo "::endgroup::"
288332 gh pr comment "$PULL_REQUEST_NUMBER" --body "$BODY"
289333 env :
334+ RELEASE : ${{matrix.release}}
290335 REMOTE_IMAGE : ghcr.io/${{github.repository_owner}}/base-ubuntu
291336 LOCAL_IMAGE_TAG : ${{steps.info.outputs.ci-image-tag}}
292337 PLATFORMS : ${{steps.info.outputs.platforms}}
0 commit comments