Skip to content

Commit 95576b1

Browse files
committed
Improve
1 parent ef69d2e commit 95576b1

File tree

3 files changed

+77
-20
lines changed

3 files changed

+77
-20
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: gha-supported-versions-parser
2+
description: |
3+
@TODO
4+
#branding: # @TODO
5+
# icon: tag
6+
# color: yellow
7+
8+
inputs:
9+
dependency:
10+
description: Dependency name to fetch
11+
required: true
12+
path:
13+
description: Path to the supported versions file
14+
required: true
15+
16+
outputs:
17+
min:
18+
description: Minimal version configured for the given dependency
19+
value: ${{ steps.parse-versions.outputs.min }}
20+
max:
21+
description: Maximal version configured for the given dependency
22+
value: ${{ steps.parse-versions.outputs.max }}
23+
next:
24+
description: Next version configured for the given dependency
25+
value: ${{ steps.parse-versions.outputs.next }}
26+
27+
runs:
28+
using: composite
29+
steps:
30+
# Even if an input is marked as "required", empty/no value may be passed !
31+
- shell: bash
32+
run: |
33+
# Validate provided inputs ...
34+
35+
if [[ -z "${{ inputs.dependency }}" ]]; then
36+
echo '::error::You must provide a dependency !'
37+
exit 1
38+
elif [[ -z "${{ inputs.path }}" ]]; then
39+
echo '::error::You must provide a path !'
40+
exit 1
41+
fi
42+
43+
- id: parse-versions
44+
shell: bash
45+
run: |
46+
# Parse ${{ inputs.dependency }} versions ...
47+
48+
# Lowest PHP version to assess (e.g Lowest supported version including security support)
49+
MIN=$( jq -r '.${{ inputs.dependency }}.min' ${{ inputs.path }} )
50+
echo "Min version: $MIN"
51+
echo "min=$MIN" >> $GITHUB_OUTPUT
52+
# Highest PHP version to assess (e.g Highest supported version)
53+
MAX=$( jq -r '.${{ inputs.dependency }}.max' ${{ inputs.path }} )
54+
echo "Min version: $MAX"
55+
echo "max=$MAX" >> $GITHUB_OUTPUT
56+
# Next (currently not supported) PHP version to assess (e.g Current dev version)
57+
NEXT=$( jq -r '.${{ inputs.dependency }}.next' ${{ inputs.path }} )
58+
echo "Min version: $NEXT"
59+
echo "next=$NEXT" >> $GITHUB_OUTPUT

.github/workflows/reusable-CI-workflow.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,30 @@ env:
1010
jobs:
1111
fetch-supported-versions:
1212
name: Fetch supported versions
13+
runs-on: ubuntu-latest
1314
env:
1415
VERSIONS_FILEPATH: .github/workflows/supported-versions.json
1516
outputs:
16-
php-min: ${{ steps.parse-versions.outputs.php-min-version }}
17-
php-max: ${{ steps.parse-versions.outputs.php-max-version }}
18-
php-next: ${{ steps.parse-versions.outputs.php-next-version }}
19-
runs-on: ubuntu-latest
17+
php-min: ${{ steps.parse-php-versions.outputs.min }}
18+
php-max: ${{ steps.parse-php-versions.outputs.max }}
19+
php-next: ${{ steps.parse-php-versions.outputs.next }}
2020
steps:
21+
22+
# @TODO Remove the following step and uncomment the next one (only there for local action usage!)
2123
- name: Check out supported version file
2224
uses: actions/checkout@v5
25+
#- name: Check out supported version file (only)
26+
# uses: actions/checkout@v5
27+
# with:
28+
# sparse-checkout: ${{ env.VERSIONS_FILEPATH }}
29+
# sparse-checkout-cone-mode: false
30+
31+
- name: Fetch versions
32+
id: parse-php-versions
33+
uses: ./.github/actions/supported-versions-parser
2334
with:
24-
sparse-checkout: ${{ env.VERSIONS_FILEPATH }}
25-
sparse-checkout-cone-mode: false
26-
- name: Parse versions
27-
id: parse-versions
28-
run: |
29-
# Lowest PHP version to assess (e.g Lowest supported version including security support)
30-
echo "php-min-version=$( jq -r '.php.min' ${{ env.VERSIONS_FILEPATH }} )" >> $GITHUB_OUTPUT
31-
# Highest PHP version to assess (e.g Highest supported version)
32-
echo "php-max-version=$( jq -r '.php.max' ${{ env.VERSIONS_FILEPATH }} )" >> $GITHUB_OUTPUT
33-
# Next (currently not supported) PHP version to assess (e.g Current dev version)
34-
echo "php-next-version=$( jq -r '.php.next' ${{ env.VERSIONS_FILEPATH }} )" >> $GITHUB_OUTPUT
35+
dependency: php
36+
path: ${{ env.VERSIONS_FILEPATH }}
3537
tests:
3638
name: ${{ matrix.job-name }}
3739
needs: [fetch-supported-versions]
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
{
2-
"php": {
3-
"min": "8.0",
4-
"max": "8.4",
5-
"next": "8.5"
6-
}
2+
"php": {"min": "8.0", "max": "8.4", "next": "8.5"}
73
}

0 commit comments

Comments
 (0)