Skip to content

Commit def408e

Browse files
author
Greg Bowler
committed
feature: pass own phar
1 parent 9e3acee commit def408e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The following configuration options are available:
4848
+ `version` The version of PHPStan to use e.g. `9` or `9.5.0` (default: latest)
4949
+ `php_version` The version of PHP to use e.g. `7.4` (default: latest)
5050
+ `php_extensions` Space-separated list of extensions using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A)
51+
+ `vendored_phpstan_path` The path to a phar file already present on the runner (default: N/A)
5152
+ `command` The command to run e.g. `list` or `worker` (default: analyse)
5253
+ `path` Path(s) with source code to run analysis on, space-separated (required)
5354
+ `configuration` Configuration file location

action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ inputs:
1616
description: Space separated list of extensions to configure with the PHP build
1717
required: false
1818

19+
vendored_phpstan_path:
20+
description: Path to a vendored phpstan binary
21+
required: false
22+
1923
command:
2024
description: The command to run (analyse [default], clear-result-cache, dump-deps, help, list, worker)
2125
required: true
@@ -64,6 +68,7 @@ runs:
6468
ACTION_TOKEN: ${{ github.token }}
6569
ACTION_VERSION: ${{ inputs.version }}
6670
ACTION_PHP_VERSION: ${{ inputs.php_version }}
71+
ACTION_PHPSTAN_PATH: ${{ inputs.vendored_phpstan_path }}
6772
ACTION_PHP_EXTENSIONS: ${{ inputs.php_extensions }}
6873
ACTION_COMMAND: ${{ inputs.command }}
6974
ACTION_PATH: ${{ inputs.path }}

phpstan-action.bash

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ github_action_path=$(dirname "$0")
44
docker_tag=$(cat ./docker_tag)
55
echo "Docker tag: $docker_tag" >> output.log 2>&1
66

7-
phar_url="https://www.getrelease.download/phpstan/phpstan/$ACTION_VERSION/phar"
8-
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "${github_action_path}/phpstan.phar"
9-
chmod +x "${github_action_path}/phpstan.phar"
7+
if [ -z "$ACTION_PHPSTAN_PATH" ]
8+
then
9+
phar_url="https://www.getrelease.download/phpstan/phpstan/$ACTION_VERSION/phar"
10+
phar_path="${github_action_path}/phpstan.phar"
11+
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path"
12+
else
13+
phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPSTAN_PATH"
14+
fi
1015

16+
chmod +x "$phar_path"
1117
command_string=("phpstan")
1218

1319
if [ -n "$ACTION_COMMAND" ]
@@ -83,10 +89,9 @@ do
8389
done <<<$(env)
8490

8591
echo "Command: " "${command_string[@]}" >> output.log 2>&1
86-
echo "::set-output name=full_command::${command_string}"
8792

8893
docker run --rm \
89-
--volume "${github_action_path}/phpstan.phar":/usr/local/bin/phpstan \
94+
--volume "$phar_path":/usr/local/bin/phpstan \
9095
--volume "${GITHUB_WORKSPACE}":/app \
9196
--workdir /app \
9297
--env-file ./DOCKER_ENV \

0 commit comments

Comments
 (0)