-
Notifications
You must be signed in to change notification settings - Fork 39
/
entrypoint.sh
executable file
·45 lines (33 loc) · 922 Bytes
/
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
#!/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}")"
WORKING_DIR="$(dirname "${CONFIG_ABS_PATH}")"
cd "$WORKING_DIR" || exit
ARGS=(
"$@"
--config "$CONFIG_ABS_PATH"
)
# 'check' sub-command doesn't require credentials
if [ "$1" != "check" ]; then
ARGS+=(--creds "$CREDS_ABS_PATH")
fi
IFS=
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