Improve composer.json php version selection
This commit is contained in:
parent
ce4e0f729f
commit
20ceab239c
1 changed files with 8 additions and 1 deletions
|
@ -31,14 +31,21 @@ runs:
|
||||||
# if composer.json exists, set the php_version output
|
# if composer.json exists, set the php_version output
|
||||||
if [ -f composer.json ]; then
|
if [ -f composer.json ]; then
|
||||||
# And that the require php key exists
|
# And that the require php key exists
|
||||||
|
echo -n "composer.json exists"
|
||||||
if jq -e '.require["php"]' composer.json > /dev/null; then
|
if jq -e '.require["php"]' composer.json > /dev/null; then
|
||||||
php_version=$(jq -r '.require["php"]' composer.json | sed -E 's/[^0-9.]//g')
|
php_version=$(jq -r '.require["php"]' composer.json | sed -E 's/[^0-9.]//g')
|
||||||
echo "Detected PHP version $php_version from composer.json"
|
echo "and detected PHP version $php_version from composer.json!"
|
||||||
echo "php_version=$php_version" >> $GITHUB_OUTPUT
|
echo "php_version=$php_version" >> $GITHUB_OUTPUT
|
||||||
echo "has_composer=true" >> $GITHUB_OUTPUT
|
echo "has_composer=true" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
|
else
|
||||||
|
echo " ... But does not specify a PHP version!"
|
||||||
|
echo "Please go set a PHP version in the require key of your composer.json"
|
||||||
|
exit 1;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "No PHP version detected"
|
||||||
|
exit 0;
|
||||||
- uses: shivammathur/setup-php@v2
|
- uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ steps.read-php-version.outputs.php_version }}
|
php-version: ${{ steps.read-php-version.outputs.php_version }}
|
||||||
|
|
Loading…
Reference in a new issue