@@ -30,76 +30,75 @@ concurrency:
3030 cancel-in-progress : true
3131
3232jobs :
33+ setup :
34+ runs-on : ubuntu-latest
35+ outputs :
36+ matrix : ${{ steps.matrix.outputs.matrix }}
37+ s6_version : ${{ steps.s6.outputs.version }}
38+ steps :
39+ - name : Compute build matrix
40+ id : matrix
41+ run : |
42+ if [ "${{ github.event_name }}" = "pull_request" ]; then
43+ PHP_VERSIONS='["8.4","8.2"]'
44+ echo "::notice::PR detected — testing PHP 8.4 + 8.2 only (skipping 8.3)"
45+ else
46+ PHP_VERSIONS='["8.4","8.3","8.2"]'
47+ fi
48+
49+ # Build trixie include list for v2 based on selected PHP versions
50+ INCLUDES="[]"
51+ for ver in $(echo "$PHP_VERSIONS" | jq -r '.[]'); do
52+ for type in fpm cli apache; do
53+ INCLUDES=$(echo "$INCLUDES" | jq -c ". + [{\"variant\":\"v2\",\"php-version\":\"$ver\",\"php-type\":\"$type\",\"php-base\":\"trixie\"}]")
54+ done
55+ done
56+
57+ MATRIX=$(jq -n -c \
58+ --argjson versions "$PHP_VERSIONS" \
59+ --argjson includes "$INCLUDES" \
60+ '{
61+ "variant": ["v1","v2"],
62+ "php-version": $versions,
63+ "php-type": ["fpm","cli","apache"],
64+ "php-base": ["alpine","bookworm"],
65+ "exclude": [
66+ {"php-type":"apache","php-base":"alpine"},
67+ {"variant":"v2","php-base":"bookworm"}
68+ ],
69+ "include": $includes
70+ }')
71+
72+ echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
73+
74+ - name : Get latest s6-overlay version
75+ id : s6
76+ run : |
77+ set -euo pipefail
78+ RESPONSE="$(curl -fSLs \
79+ -H "Authorization: Bearer ${{ github.token }}" \
80+ https://api.github.com/repos/just-containers/s6-overlay/releases/latest)"
81+ S6_OVERLAY_VERSION="$(echo "$RESPONSE" | jq -r .tag_name)"
82+ if [ -z "$S6_OVERLAY_VERSION" ] || [ "$S6_OVERLAY_VERSION" = "null" ]; then
83+ echo "::error::Failed to determine s6-overlay version"
84+ exit 1
85+ fi
86+ echo "version=${S6_OVERLAY_VERSION}" >> $GITHUB_OUTPUT
87+ echo "✅ Latest s6-overlay version: ${S6_OVERLAY_VERSION}"
88+
3389 build-and-test :
90+ needs : setup
3491 runs-on : ubuntu-latest
3592 strategy :
3693 fail-fast : false
37- matrix :
38- variant : [v1, v2]
39- php-version : ['8.4', '8.3', '8.2']
40- php-type : [fpm, cli, apache]
41- php-base : [alpine, bookworm]
42- exclude :
43- - php-type : apache
44- php-base : alpine
45- - variant : v2
46- php-base : bookworm
47- include :
48- - variant : v2
49- php-version : ' 8.4'
50- php-type : fpm
51- php-base : trixie
52- - variant : v2
53- php-version : ' 8.4'
54- php-type : cli
55- php-base : trixie
56- - variant : v2
57- php-version : ' 8.4'
58- php-type : apache
59- php-base : trixie
60- - variant : v2
61- php-version : ' 8.3'
62- php-type : fpm
63- php-base : trixie
64- - variant : v2
65- php-version : ' 8.3'
66- php-type : cli
67- php-base : trixie
68- - variant : v2
69- php-version : ' 8.3'
70- php-type : apache
71- php-base : trixie
72- - variant : v2
73- php-version : ' 8.2'
74- php-type : fpm
75- php-base : trixie
76- - variant : v2
77- php-version : ' 8.2'
78- php-type : cli
79- php-base : trixie
80- - variant : v2
81- php-version : ' 8.2'
82- php-type : apache
83- php-base : trixie
94+ matrix : ${{ fromJson(needs.setup.outputs.matrix) }}
8495
8596 name : ${{ matrix.variant }}-${{ matrix.php-version }}-${{ matrix.php-type }}-${{ matrix.php-base }}
8697
8798 steps :
8899 - name : Checkout
89100 uses : actions/checkout@v4
90101
91- - name : Get latest s6-overlay version
92- id : s6-version
93- run : |
94- S6_OVERLAY_VERSION="$(curl -s https://api.github.com/repos/just-containers/s6-overlay/releases/latest | jq -r .tag_name)"
95- echo "version=${S6_OVERLAY_VERSION}" >> $GITHUB_OUTPUT
96- echo "✅ Latest s6-overlay version: ${S6_OVERLAY_VERSION}"
97-
98- - name : Setup QEMU
99- uses : docker/setup-qemu-action@v3
100- with :
101- platforms : amd64,arm64,arm
102-
103102 - name : Setup Docker Buildx
104103 uses : docker/setup-buildx-action@v3
105104
@@ -138,7 +137,7 @@ jobs:
138137 VERSION=${{ steps.vars.outputs.VERSION }}
139138 PHPVERSION=${{ matrix.php-version }}
140139 BASEOS=${{ matrix.php-base }}
141- S6_OVERLAY_VERSION=${{ steps.s6-version .outputs.version }}
140+ S6_OVERLAY_VERSION=${{ needs.setup .outputs.s6_version }}
142141 BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
143142 VCS_REF=${{ github.sha }}
144143 tags : test-${{ steps.vars.outputs.TAG }}
@@ -295,7 +294,7 @@ jobs:
295294 echo "::notice::✅ Build and tests passed for ${{ matrix.variant }} - ${{ steps.vars.outputs.TAG }}"
296295
297296 publish :
298- needs : build-and-test
297+ needs : [setup, build-and-test]
299298 if : github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'schedule')
300299 runs-on : ubuntu-latest
301300 strategy :
@@ -356,13 +355,6 @@ jobs:
356355 - name : Checkout
357356 uses : actions/checkout@v4
358357
359- - name : Get latest s6-overlay version
360- id : s6-version
361- run : |
362- S6_OVERLAY_VERSION="$(curl -s https://api.github.com/repos/just-containers/s6-overlay/releases/latest | jq -r .tag_name)"
363- echo "version=${S6_OVERLAY_VERSION}" >> $GITHUB_OUTPUT
364- echo "✅ Latest s6-overlay version: ${S6_OVERLAY_VERSION}"
365-
366358 - name : Setup QEMU
367359 uses : docker/setup-qemu-action@v3
368360 with :
@@ -429,7 +421,7 @@ jobs:
429421 VERSION=${{ steps.vars.outputs.VERSION }}
430422 PHPVERSION=${{ matrix.php-version }}
431423 BASEOS=${{ matrix.php-base }}
432- S6_OVERLAY_VERSION=${{ steps.s6-version .outputs.version }}
424+ S6_OVERLAY_VERSION=${{ needs.setup .outputs.s6_version }}
433425 BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
434426 VCS_REF=${{ github.sha }}
435427 tags : |
0 commit comments