forked from koenrh/dnscontrol-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·73 lines (55 loc) · 1.49 KB
/
entrypoint.sh
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
set -o pipefail
# Resolve to full paths
CONFIG_ABS_PATH="$(readlink -f "${INPUT_CONFIG_FILE}")"
CREDS_ABS_PATH="$(readlink -f "${INPUT_CREDS_FILE}")"
ALLOW_FETCH="${ALLOW_FETCH:-false}"
DISABLE_ORDERED_UPDATE="${DISABLE_ORDERED_UPDATE:-false}"
ENABLE_COLORS="${ENABLE_COLORS:-false}"
ENABLE_CONCURRENT="${ENABLE_CONCURRENT:-true}"
WORKING_DIR="$(dirname "${CONFIG_ABS_PATH}")"
cd "$WORKING_DIR" || exit
ARGS=()
if [ "$ENABLE_COLORS" = false ]; then
ARGS+=(--no-colors)
fi
if [ "$DISABLE_ORDERED_UPDATE" = true ]; then
ARGS+=(--disableordering)
fi
if [ "$ALLOW_FETCH" = true ]; then
ARGS+=(--allow-fetch)
fi
ARGS+=(
"$@"
--config "$CONFIG_ABS_PATH"
)
# 'check' sub-command doesn't require credentials
if [ "$1" != "check" ]; then
ARGS+=(--creds "$CREDS_ABS_PATH")
if [ "$ENABLE_CONCURRENT" = false ]; then
ARGS+=(--cmode "legacy")
else
ARGS+=(--cmode "concurrent")
fi
fi
OUTPUT=()
OUTPUT+=("Running dnscontrol with args: ${ARGS[@]}")
OUTPUT+=("Input args: $@")
OUTPUT="$(dnscontrol "${ARGS[@]}")"
EXIT_CODE="$?"
echo "$OUTPUT"
# Filter output to reduce 'preview' PR comment length
FILTERED_OUTPUT="$(echo "$OUTPUT" | /filter-preview-output.sh)"
# Set output
# https://github.com/orgs/community/discussions/26288#discussioncomment-3876281
DELIMITER="DNSCONTROL-$RANDOM"
{
echo "output<<$DELIMITER"
echo "$OUTPUT"
echo "$DELIMITER"
echo "preview_comment<<$DELIMITER"
echo "$FILTERED_OUTPUT"
echo "$DELIMITER"
} >>"$GITHUB_OUTPUT"
exit $EXIT_CODE
exit 1