-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.bash
executable file
·73 lines (57 loc) · 1.85 KB
/
script.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
#!/usr/bin/env bash
ARGS=()
function add_args() {
ARGS+=("$1")
}
function exit_script() {
local code=$1
echo exit-code="$code" >> "$GITHUB_OUTPUT"
exit "$code"
}
AUTIFY=${INPUT_AUTIFY_PATH}
if [ -z "${INPUT_ACCESS_TOKEN}" ]; then
echo "Missing access-token."
exit_script 1
fi
if [ -n "${INPUT_AUTIFY_TEST_URL}" ]; then
add_args "${INPUT_AUTIFY_TEST_URL}"
else
echo "Missing autify-test-url."
exit_script 1
fi
if [ -n "${INPUT_BUILD_ID}" ] && [ -n "${INPUT_BUILD_PATH}" ]; then
echo "Can't specify both build-id and build-path."
exit_script 1
elif [ -n "${INPUT_BUILD_ID}" ]; then
add_args "--build-id=${INPUT_BUILD_ID}"
elif [ -n "${INPUT_BUILD_PATH}" ]; then
add_args "--build-path=${INPUT_BUILD_PATH}"
else
echo "Specify either build-id or build-path."
exit_script 1
fi
if [ "${INPUT_WAIT}" = "true" ]; then
add_args "--wait"
fi
if [ -n "${INPUT_TIMEOUT}" ]; then
add_args "-t=${INPUT_TIMEOUT}"
fi
if [ -n "${INPUT_MAX_RETRY_COUNT}" ]; then
add_args "--max-retry-count=${INPUT_MAX_RETRY_COUNT}"
fi
export AUTIFY_CLI_USER_AGENT_SUFFIX="${AUTIFY_CLI_USER_AGENT_SUFFIX:=github-actions-mobile-test-run}"
OUTPUT=$(mktemp)
AUTIFY_MOBILE_ACCESS_TOKEN=${INPUT_ACCESS_TOKEN} ${AUTIFY} mobile test run "${ARGS[@]}" 2>&1 | tee "$OUTPUT"
exit_code=${PIPESTATUS[0]}
# Workaround to return multiline string as outputs
# https://trstringer.com/github-actions-multiline-strings/
output=$(cat "$OUTPUT")
output="${output//'%'/%25}"
output="${output//$'\n'/%0A}"
output="${output//$'\r'/%0D}"
echo log="$output" >> "$GITHUB_OUTPUT"
result=$(grep "Successfully started" "$OUTPUT" | grep -Eo 'https://[^ ]+' | head -1)
echo result-url="$result" >> "$GITHUB_OUTPUT"
build_id=$(grep "Successfully uploaded" "$OUTPUT" | grep -Eo 'ID: [^\)]+' | cut -f2 -d' ' | head -1)
echo build-id="${build_id:-$INPUT_BUILD_ID}" >> "$GITHUB_OUTPUT"
exit_script "$exit_code"