-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathphpmd-action.bash
More file actions
executable file
·98 lines (81 loc) · 2.05 KB
/
phpmd-action.bash
File metadata and controls
executable file
·98 lines (81 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
set -e
github_action_path=$(dirname "$0")
docker_tag=$(cat ./docker_tag)
echo "Docker tag: $docker_tag" >> output.log 2>&1
if [ "$ACTION_VERSION" = "composer" ]
then
VENDOR_BIN="vendor/bin/phpmd"
if test -f "$VENDOR_BIN"
then
ACTION_PHPMD_PATH="$VENDOR_BIN"
else
echo "Trying to use version installed by Composer, but there is no file at $VENDOR_BIN"
exit 1
fi
fi
if [ -z "$ACTION_PHPMD_PATH" ]
then
phar_url="https://www.getrelease.download/phpmd/phpmd/$ACTION_VERSION/phar"
phar_path="${github_action_path}/phpmd.phar"
command_string=("phpmd")
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path"
else
phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPMD_PATH"
command_string=($ACTION_PHPMD_PATH)
fi
if [ ! -f "${phar_path}" ]
then
echo "Error: The phpmd binary \"${phar_path}\" does not exist in the project"
exit 1
fi
echo "::debug::phar_path=$phar_path"
if [[ ! -x "$phar_path" ]]
then
chmod +x $phar_path || echo "Error: the PHAR must have executable bit set" && exit 1
fi
if [ -n "$ACTION_PATH" ]
then
command_string+=("$ACTION_PATH")
fi
if [ -n "$ACTION_OUTPUT" ]
then
command_string+=("$ACTION_OUTPUT")
fi
if [ -n "$ACTION_RULESET" ]
then
command_string+=("$ACTION_RULESET")
fi
if [ -n "$ACTION_MINIMUMPRIORITY" ]
then
command_string+=(--minimumpriority "$ACTION_MINIMUMPRIORITY")
fi
if [ -n "$ACTION_REPORTFILE" ]
then
command_string+=(--reportfile "$ACTION_REPORTFILE")
fi
if [ -n "$ACTION_SUFFIXES" ]
then
command_string+=(--suffixes "$ACTION_SUFFIXES")
fi
if [ -n "$ACTION_EXCLUDE" ]
then
command_string+=(--exclude "$ACTION_EXCLUDE")
fi
if [ -n "$ACTION_STRICT" ]
then
command_string+=(--strict)
fi
if [ -n "$ACTION_ARGS" ]
then
command_string+=($ACTION_ARGS)
fi
echo "::debug::PHPMD Command: ${command_string[@]}"
docker run --rm \
--volume "$phar_path":/usr/local/bin/phpmd \
--volume "${GITHUB_WORKSPACE}/vendor/phpmd:/usr/local/phpmd" \
--volume "${GITHUB_WORKSPACE}":/app \
--workdir /app \
--network host \
--env-file <( env| cut -f1 -d= ) \
${docker_tag} "${command_string[@]}"