Skip to content

Commit 128bf9f

Browse files
committed
Auto detect php version
1 parent 11085b6 commit 128bf9f

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: # yamllint disable-line rule:truthy
55
inputs:
66
php-versions:
77
description: "The PHP versions to use when running the job"
8-
default: "['7.4', '8.0', '8.1', '8.2', '8.3']"
8+
default: "auto-detect"
99
required: false
1010
type: "string"
1111
php-extensions:
@@ -29,14 +29,42 @@ on: # yamllint disable-line rule:truthy
2929
type: "string"
3030

3131
jobs:
32+
supported-versions-matrix:
33+
name: "Supported Versions Matrix"
34+
runs-on: "ubuntu-latest"
35+
outputs:
36+
extensions: "${{ steps.supported-versions-matrix.outputs.extensions }}"
37+
version: "${{ steps.supported-versions-matrix.outputs.version }}"
38+
steps:
39+
- uses: "actions/checkout@v4"
40+
if: "${{ inputs.php-versions == 'auto-detect' }}"
41+
42+
- id: "supported-versions-detect"
43+
if: "${{ inputs.php-versions == 'auto-detect' }}"
44+
uses: "WyriHaximus/github-action-composer-php-versions-in-range@v1"
45+
46+
47+
- name: "Set PHP versions"
48+
with:
49+
inputVersions: "${{ inputs.php-versions }}"
50+
inputExtensions: "${{ inputs.php-extensions }}"
51+
detectedVersions: "${{ steps.supported-versions-detect.outputs.versions }}"
52+
detectedExtensions: "${{ join(fromJson(steps.supported-versions-detect.outputs.version), ',') }}"
53+
54+
id: "supported-versions-matrix"
55+
run: |
56+
echo "version=[[ $inputVersions != "auto-detect" ]] $detected-versions || $inputVersions " >> $GITHUB_ENV
57+
echo "extensions=[[ $inputVersions != "auto-detect" ]] $detectedExtensions || $inputExtensions " >> $GITHUB_ENV
58+
3259
tests:
3360
name: "Tests"
3461

3562
runs-on: "ubuntu-latest"
3663

64+
needs: "supported-versions-matrix"
3765
strategy:
3866
matrix:
39-
php-version: "${{ fromJson(inputs.php-versions) }}"
67+
php-version: "${{ fromJson(needs.supported-versions-matrix.outputs.version) }}"
4068
dependencies:
4169
- "lowest"
4270
- "locked"

0 commit comments

Comments
 (0)