-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·63 lines (50 loc) · 1.37 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
#!/bin/sh -l
set -e
closing=$(get-closing-labels -o $INPUT_OWNER -n $INPUT_REPO -p $INPUT_PR_NUMBER)
if [ "$closing" = "[]" ]; then
echo "No closing labels found, exiting."
exit 0
fi
removed=$(get-removed-labels -o $INPUT_OWNER -n $INPUT_REPO -p $INPUT_PR_NUMBER)
echo "Closing labels: $closing"
echo "Removed labels: $removed"
echo "Input ignore: $INPUT_EXCLUDE"
echo "Input respect_unlabeled: $INPUT_RESPECT_UNLABELED"
labels=$(
echo "{}" | jq -r \
--argjson closing "$closing" \
--argjson removed "$removed" \
--arg ignore "$INPUT_EXCLUDE" \
--arg respect_unlabeled "$INPUT_RESPECT_UNLABELED" '
def split_ignore:
if $ignore == "" then
[]
else
$ignore | split(",")
end;
def create_result:
if $respect_unlabeled == "true" then
$closing - $removed
else
$closing
end;
split_ignore as $ignore_split |
create_result as $result |
{
closing: $closing,
removed: $removed,
ignore: $ignore_split,
result: ($result - $ignore_split),
} | .result | join(",")
'
)
echo "Adding label(s): $labels"
if [ "$labels" = "" ]; then
echo "No labels to add"
exit 0
fi
if [ "$INPUT_DRY_RUN" = "true" ]; then
echo "Dry run enabled, skipping adding labels"
exit 0
fi
gh pr edit $INPUT_PR_NUMBER --add-label "$labels" --repo "$INPUT_OWNER/$INPUT_REPO"