Skip to content

Commit e865fb7

Browse files
author
Greg Bowler
committed
expose host environment variables to docker runner
1 parent f15c418 commit e865fb7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

phpstan-action.bash

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,29 @@ then
6060
command_string+=($ACTION_ARGS)
6161
fi
6262

63+
dockerKeys=()
64+
while IFS= read -r line
65+
do
66+
dockerKeys+=( $(echo "$line" | cut -f1 -d=) )
67+
done <<<$(docker run --rm "${docker_tag}" env)
68+
69+
while IFS= read -r line
70+
do
71+
key=$(echo "$line" | cut -f1 -d=)
72+
if printf '%s\n' "${dockerKeys[@]}" | grep -q -P "^${key}\$"
73+
then
74+
echo "Skipping env variable $key" >> output.log
75+
else
76+
echo "$line" >> DOCKER_ENV
77+
fi
78+
done <<<$(env)
79+
6380
echo "Command: " "${command_string[@]}" >> output.log 2>&1
81+
echo "::set-output name=full_command::${command_string}"
82+
6483
docker run --rm \
6584
--volume "${github_action_path}/phpstan.phar":/usr/local/bin/phpstan \
6685
--volume "${GITHUB_WORKSPACE}":/app \
6786
--workdir /app \
87+
--env-file ./DOCKER_ENV \
6888
${docker_tag} "${command_string[@]}"

0 commit comments

Comments
 (0)