Skip to content

Commit c549415

Browse files
authored
Merge pull request #5 from php-actions/path-update
Update paths for v2
2 parents 5e43612 + cb0b3e5 commit c549415

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: PHP Mess Detector
3232
uses: php-actions/phpmd@v1
3333
with:
34-
php_version: 8.1
34+
php_version: 8.4
3535
path: src/
3636
output: text
3737
ruleset: test/phpmd/ruleset.xml
@@ -49,8 +49,8 @@ Inputs
4949

5050
The following configuration options are available:
5151

52-
+ `version` - What version of PHPMD to use
53-
+ `php_version` - What version of PHP to use
52+
+ `version` - What version of PHPMD to use e.g. `latest`, or `9`, or `9.5.0` (default: `composer` - use the version specified in composer.json)
53+
+ `php_version` - What version of PHP to use e.g. `8.4` (default: latest)
5454
+ `vendored_phpmd_path` - Path to a vendored phpmd binary
5555
+ `path` - A php source code filename or directory. Can be a comma-separated string
5656
+ `ruleset` - A ruleset filename or a comma-separated string of rulesetfilenames

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Run your PHP Mess Detector tests in your Github Actions.
44
inputs:
55
version:
66
description: What version of PHPMD to use
7-
default: latest
7+
default: composer
88
required: false
99

1010
php_version:
@@ -74,7 +74,7 @@ runs:
7474
id: phpmd_run
7575
run: |
7676
set -e
77-
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cee5b9fa9fbc4c888e7a62bbb7b8eade18e3c56b/php-build.bash) phpmd
77+
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/59e915e4b8eeab830231a5dce6ad0998adebac05/php-build.bash) phpmd
7878
${{ github.action_path }}/phpmd-action.bash
7979
shell: bash
8080

phpmd-action.bash

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ set -e
33
github_action_path=$(dirname "$0")
44
docker_tag=$(cat ./docker_tag)
55

6+
echo "Docker tag: $docker_tag" >> output.log 2>&1
7+
8+
if [ "$ACTION_VERSION" = "composer" ]
9+
then
10+
VENDOR_BIN="vendor/bin/phpmd"
11+
if test -f "$VENDOR_BIN"
12+
then
13+
ACTION_PHPMD_PATH="$VENDOR_BIN"
14+
else
15+
echo "Trying to use version installed by Composer, but there is no file at $VENDOR_BIN"
16+
exit 1
17+
fi
18+
fi
19+
620
if [ -z "$ACTION_PHPMD_PATH" ]
721
then
822
phar_url="https://www.getrelease.download/phpmd/phpmd/$ACTION_VERSION/phar"
@@ -74,20 +88,11 @@ fi
7488

7589
echo "::debug::PHPMD Command: ${command_string[@]}"
7690

77-
if [ -z "$ACTION_PHPMD_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
91+
docker run --rm \
92+
--volume "$phar_path":/usr/local/bin/phpmd \
93+
--volume "${GITHUB_WORKSPACE}/vendor/phpmd:/usr/local/phpmd" \
94+
--volume "${GITHUB_WORKSPACE}":/app \
95+
--workdir /app \
96+
--network host \
97+
--env-file <( env| cut -f1 -d= ) \
98+
${docker_tag} "${command_string[@]}"

0 commit comments

Comments
 (0)