-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.bash
executable file
·53 lines (41 loc) · 1.24 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
#!/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_BUILD_PATH}" ]; then
add_args "${INPUT_BUILD_PATH}"
else
echo "Missing build-path."
exit_script 1
fi
if [ -n "${INPUT_WORKSPACE_ID}" ]; then
add_args "--workspace-id=${INPUT_WORKSPACE_ID}"
else
echo "Missing workspace-id."
exit_script 1
fi
export AUTIFY_CLI_USER_AGENT_SUFFIX="${AUTIFY_CLI_USER_AGENT_SUFFIX:=github-actions-mobile-build-upload}"
OUTPUT=$(mktemp)
AUTIFY_MOBILE_ACCESS_TOKEN=${INPUT_ACCESS_TOKEN} ${AUTIFY} mobile build upload "${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"
build_id=$(grep "Successfully uploaded" "$OUTPUT" | grep -Eo 'ID: [^\)]+' | cut -f2 -d' ' | head -1)
echo build-id="$build_id" >> "$GITHUB_OUTPUT"
exit_script "$exit_code"