-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·48 lines (35 loc) · 1.28 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
#!/bin/bash
set -u # this will give us a warning every time we use undeclared variable
# token paramter is the first paramter so we can refer to it using index
repo_token=$1
if [ "$GITHUB_EVENT_NAME" != "milestone" ]; then
# this will appear only when DEBUG mode is enabled in the workflow
echo "::debug::The even name was '$GITHUB_EVENT_NAME'"
exit 0
fi
evenType=$(jq --raw-output .action $GITHUB_EVENT_PATH)
if [ $evenType != "closed" ]; then
echo "::debug::The event type was '$event_type'"
exit 0
fi
milestone_name=$(jq --raw-output .milestone.title $GITHUB_EVENT_PATH)
# https://bash.cyberciti.biz/guide/$IFS
# Internal Field Separator
# <<<: here-string redirection operator
# https://tldp.org/LDP/abs/html/x17837.html
IFS='/' read owner repository <<< "$GITHUB_REPOSITORY"
release_url=$(dotnet gitreleasemanager create \
--milestone $milestone_name \
--name $milestone_name \
--targetcommitish $GITHUB_SHA \
--token $repo_token \
--owner $owner \
--repository $repository)
# to get exit code of the last executed command use syntax: $?
if [ $? -ne 0 ]; then
echo "::error::Failed to create the release draft"
exit 1
fi
# From unkwnon reason the output paramter is not set but the draft release is published
echo '::set-output name=release-url::$release_url'
exit 0