|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
| 3 | +github_action_path=$(dirname "$0") |
| 4 | +docker_tag=$(cat ./docker_tag) |
| 5 | +echo "Docker tag: $docker_tag" >> output.log 2>&1 |
3 | 6 |
|
4 | | -Get_command() |
5 | | -{ |
6 | | - echo -n "phpstan --no-interaction --no-progress ${action_command}" |
7 | | - for env in action_configuration action_level \ |
8 | | - action_paths_file action_autoload_file action_error_format \ |
9 | | - action_generate_baseline action_memory_limit |
10 | | - do |
11 | | - option="${!env}" |
12 | | - option_name="${env#action_}" |
13 | | - if [ -z "${option}" ]; then |
14 | | - continue |
15 | | - fi |
16 | | - echo -n " --${option_name//_/-}='${option}'" |
17 | | - done |
18 | | - echo -n " ${action_args} ${action_path}" |
19 | | -} |
20 | | - |
21 | | -command_string="$(Get_command)" |
22 | | - |
23 | | -echo "Command: ${command_string}" |
24 | | -eval "${command_string}" |
| 7 | +# TODO: Download phar from Github |
| 8 | +phar_url="https://getrelease.download?repo=phpstan&version=$ACTION_VERSION" |
| 9 | +curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "${github_action_path}/phpstan.phar" |
| 10 | +chmod +x "${github_action_path}/phpunit.phar" |
| 11 | + |
| 12 | +command_string=("phpstan") |
| 13 | + |
| 14 | +if [ -n "$ACTION_COMMAND" ] |
| 15 | +then |
| 16 | + command_string+=("$ACTION_COMMAND") |
| 17 | +fi |
| 18 | + |
| 19 | +if [ -n "$ACTION_PATH" ] |
| 20 | +then |
| 21 | + command_string+=("$ACTION_PATH") |
| 22 | +fi |
| 23 | + |
| 24 | +if [ -n "$ACTION_CONFIGURATION" ] |
| 25 | +then |
| 26 | + command_string+=(--configuration="$ACTION_CONFIGURATION") |
| 27 | +fi |
| 28 | + |
| 29 | +if [ -n "$ACTION_LEVEL" ] |
| 30 | +then |
| 31 | + command_string+=(--level="$ACTION_LEVEL") |
| 32 | +fi |
| 33 | + |
| 34 | +if [ -n "$ACTION_PATHS_FILE" ] |
| 35 | +then |
| 36 | + command_string+=(--paths-file="$ACTION_PATHS_FILE") |
| 37 | +fi |
| 38 | + |
| 39 | +if [ -n "$ACTION_AUTOLOAD_FILE" ] |
| 40 | +then |
| 41 | + command_string+=(--autoload-file="$ACTION_AUTOLOAD_FILE") |
| 42 | +fi |
| 43 | + |
| 44 | +if [ -n "$ACTION_ERROR_FORMAT" ] |
| 45 | +then |
| 46 | + command_string+=(--error-format="ACTION_ERROR_FORMAT") |
| 47 | +fi |
| 48 | + |
| 49 | +if [ -n "$ACTION_GENERATE_BASELINE" ] |
| 50 | +then |
| 51 | + command_string+=(--generate-baseline="$ACTION_GENERATE_BASELINE") |
| 52 | +fi |
| 53 | + |
| 54 | +if [ -n "$ACTION_MEMORY_LIMIT" ] |
| 55 | +then |
| 56 | + command_string+=(--memory-limit="$ACTION_MEMORY_LIMIT") |
| 57 | +fi |
| 58 | + |
| 59 | +if [ -n "$ACTION_ARGS" ] |
| 60 | +then |
| 61 | + command_string+=($ACTION_ARGS) |
| 62 | +fi |
| 63 | + |
| 64 | +echo "Command: " "${command_string[@]}" >> output.log 2>&1 |
| 65 | +docker run --rm \ |
| 66 | + --volume "${github_action_path}/phpstan.phar":/usr/local/bin/phpstan \ |
| 67 | + --volume "${GITHUB_WORKSPACE}":/app \ |
| 68 | + --workdir /app \ |
| 69 | + ${docker_tag} "${command_string[@]}" |
0 commit comments