-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbehat-action.bash
executable file
·97 lines (80 loc) · 1.93 KB
/
behat-action.bash
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
#!/bin/bash
set -e
github_action_path=$(dirname "$0")
docker_tag=$(cat ./docker_tag)
echo "Docker tag: $docker_tag" >> output.log 2>&1
if [ -z "$ACTION_BEHAT_PATH" ]
then
phar_url="https://www.getrelease.download/Behat/Behat/$ACTION_VERSION/phar"
phar_path="${github_action_path}/behat.phar"
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path"
else
phar_path="${GITHUB_WORKSPACE}/$ACTION_BEHAT_PATH"
fi
chmod +x "$phar_path"
command_string=("behat")
if [ -n "$ACTION_CONFIG" ]
then
command_string+=(--config="$ACTION_CONFIG")
fi
if [ -n "$ACTION_SUITE" ]
then
command_string+=(--suite="$ACTION_SUITE")
fi
if [ -n "$ACTION_FORMAT" ]
then
command_string+=(--format="$ACTION_FORMAT")
fi
if [ -n "$ACTION_OUT" ]
then
command_string+=(--out="$ACTION_OUT")
fi
if [ -n "$ACTION_NAME" ]
then
command_string+=(--name="$ACTION_NAME")
fi
if [ -n "$ACTION_TAGS" ]
then
command_string+=(--tags="$ACTION_TAGS")
fi
if [ -n "$ACTION_ROLE" ]
then
command_string+=(--role="$ACTION_ROLE")
fi
if [ -n "$ACTION_DEFINITIONS" ]
then
command_string+=(--definitions="$ACTION_DEFINITIONS")
fi
if [ -n "$ACTION_ARGS" ]
then
command_string+=($ACTION_ARGS)
fi
command_string+=(--no-interaction)
command_string+=(--colors)
if [ -n "$ACTION_PATHS" ]
then
command_string+=("$ACTION_PATHS")
fi
dockerKeys=()
while IFS= read -r line
do
dockerKeys+=( $(echo "$line" | cut -f1 -d=) )
done <<<$(docker run --rm "${docker_tag}" env)
while IFS= read -r line
do
key=$(echo "$line" | cut -f1 -d=)
if printf '%s\n' "${dockerKeys[@]}" | grep -q -P "^${key}\$"
then
echo "Skipping env variable $key" >> output.log
else
echo "$line" >> DOCKER_ENV
fi
done <<<$(env)
echo "Command: " "${command_string[@]}" >> output.log 2>&1
docker run --rm \
--volume "$phar_path":/usr/local/bin/behat \
--volume "${GITHUB_WORKSPACE}":/app \
--workdir /app \
--env-file ./DOCKER_ENV \
--network host \
${docker_tag} "${command_string[@]}"