-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·34 lines (24 loc) · 1023 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
#!/bin/bash
set -euxo pipefail
GLUON_PATH="$1"
ALLOWLIST="${ALLOWLIST:-}"
DENYLIST="${DENYLIST:-}"
BROKEN="${BROKEN:0}"
# Get List of available Targets
AVAILABLE_TARGETS_NEWLINE="$(make --no-print-directory -C "$GLUON_PATH" list-targets "BROKEN=${BROKEN}" "GLUON_SITEDIR=docs/site-example")"
# Format Allow- and Denylist
TARGET_ALLOWLIST_NEWLINE="$(echo "$ALLOWLIST" | tr ' ' '\n')"
TARGET_DENYLIST_NEWLINE="$(echo "$DENYLIST" | tr ' ' '\n')"
# Return all available targets if no allowlist is set
OUTPUT_TARGETS="${AVAILABLE_TARGETS_NEWLINE}"
if [ -n "$ALLOWLIST" ]; then
# Only return words present in both lists
OUTPUT_TARGETS="$(echo -e "$AVAILABLE_TARGETS_NEWLINE\n$TARGET_ALLOWLIST_NEWLINE" | sort | uniq -d)"
fi
if [ -n "$DENYLIST" ]; then
# Remove words present in denylist
OUTPUT_TARGETS="$(echo -e "$OUTPUT_TARGETS\n$TARGET_DENYLIST_NEWLINE" | sort | uniq -u)"
fi
# Convert to JSON
OUTPUT_JSON="$(echo "$OUTPUT_TARGETS" | jq --raw-input . | jq --slurp . | jq -c .)"
echo "$OUTPUT_JSON"