Skip to content

Commit f80ddad

Browse files
author
Greg Bowler
authored
Merge pull request #2 from shanept/master
Fix vendored_phpmd_path
2 parents 7ae41c6 + 30f28b1 commit f80ddad

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

phpmd-action.bash

+33-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@ if [ -z "$ACTION_PHPMD_PATH" ]
77
then
88
phar_url="https://www.getrelease.download/phpmd/phpmd/$ACTION_VERSION/phar"
99
phar_path="${github_action_path}/phpmd.phar"
10+
command_string=("phpmd")
1011
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path"
1112
else
1213
phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPMD_PATH"
14+
command_string=($ACTION_PHPMD_PATH)
1315
fi
1416

15-
chmod +x $phar_path
16-
command_string=("phpmd")
17+
if [ ! -f "${phar_path}" ]
18+
then
19+
echo "Error: The phpmd binary \"${phar_path}\" does not exist in the project"
20+
exit 1
21+
fi
22+
23+
echo "::debug::phar_path=$phar_path"
24+
25+
if [[ ! -x "$phar_path" ]]
26+
then
27+
chmod +x $phar_path || echo "Error: the PHAR must have executable bit set" && exit 1
28+
fi
1729

1830
if [ -n "$ACTION_PATH" ]
1931
then
@@ -60,10 +72,22 @@ then
6072
command_string+=($ACTION_ARGS)
6173
fi
6274

63-
docker run --rm \
64-
--volume "${phar_path}":/usr/local/bin/phpmd \
65-
--volume "${GITHUB_WORKSPACE}":/app \
66-
--workdir /app \
67-
--network host \
68-
--env-file <( env| cut -f1 -d= ) \
69-
${docker_tag} "${command_string[@]}" && echo "PHPMD completed successfully"
75+
echo "::debug::PHPMD Command: ${command_string[@]}"
76+
77+
if [ -Z $ACTION_PHPUNIT_PATH ]
78+
then
79+
docker run --rm \
80+
--volume "${phar_path}":/usr/local/bin/phpmd \
81+
--volume "${GITHUB_WORKSPACE}":/app \
82+
--workdir /app \
83+
--network host \
84+
--env-file <( env| cut -f1 -d= ) \
85+
${docker_tag} "${command_string[@]}" && echo "PHPMD completed successfully"
86+
else
87+
docker run --rm \
88+
--volume "${GITHUB_WORKSPACE}":/app \
89+
--workdir /app \
90+
--network host \
91+
--env-file <( env| cut -f1 -d= ) \
92+
${docker_tag} "/app/${command_string[@]}" && echo "PHPMD completed successfully"
93+
fi

0 commit comments

Comments
 (0)