-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.sh
More file actions
39 lines (31 loc) · 763 Bytes
/
action.sh
File metadata and controls
39 lines (31 loc) · 763 Bytes
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
#!/usr/bin/env bash
get_input() {
local name="$1"
local required="${2:-false}"
local trim_whitespace="${3:-true}"
local var_name="INPUT_$(echo "$name" | tr '[:lower:]' '[:upper:]' | tr ' ' '_')"
local val="${!var_name:-}"
if [[ "$required" == "true" && -z "$val" ]]; then
echo "Error: Input required and not supplied: $name" >&2
exit 1
fi
if [[ "$trim_whitespace" == "true" ]]; then
val="$(echo "$val" | xargs)"
fi
echo "$val"
}
get_multiline_input() {
local name="$1"
local val
val="$(get_input "$name")"
echo "$val" | tr ',' '\n' | sed '/^[[:space:]]*$/d'
}
main() {
local urls
urls=($(get_multiline_input "url"))
for url in "${urls[@]}"; do
echo "→ Running: ei $url"
ei "$url"
done
}
main "$@"