-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
entrypoint.sh
executable file
·46 lines (35 loc) · 993 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
46
#!/bin/sh
set -e
prefix=${INPUT_LABEL_PREFIX}
labels=${INPUT_LABELS}
case "${GITHUB_EVENT_NAME}" in
'push')
for l in ${labels}; do
case ${l#"$prefix"} in # e.g.) 'release/major' => 'major'
'major' | 'minor' | 'patch')
if [ -z "${label}" ]; then
label="${l}"
else
label="${label}\n${l}"
fi
;;
esac
done
;;
'pull_request')
label=$(jq -r ".pull_request.labels[].name | select(test(\"$prefix(major|minor|patch)\"))" "${GITHUB_EVENT_PATH}")
;;
*)
echo "::debug:: event ${GITHUB_EVENT_NAME} not supported"
;;
esac
if [ -z "${label}" ]; then
echo "::debug:: no release label"
exit 0
fi
if [ "$(echo "${label}" | wc -l)" -ne 1 ]; then
echo "::error:: multiple release labels not allowed: labels=$(echo "${label}" | tr '\n' ' ')"
exit 1
fi
level=${label#"${prefix}"} # e.g.) 'release/major' => 'major'
echo "::set-output name=level::${level}"