@@ -14,7 +14,14 @@ Usage:
14
14
}
15
15
16
16
function github_api {
17
- curl -u " $GITHUB_USERNAME :$GITHUB_PASSWORD " -sL " https://api.github.com/repos/$GITHUB_REPO /$1 " -X " $2 " -d " $3 "
17
+ AUTHORIZATION=" $GITHUB_USER :$GITHUB_PASSWORD "
18
+ COMMAND=' -u'
19
+ [ ! -z ${GITHUB_TOKEN+x} ] && {
20
+ AUTHORIZATION=" Authorization: token $GITHUB_TOKEN "
21
+ COMMAND=' -H'
22
+ }
23
+
24
+ curl $COMMAND " $AUTHORIZATION " -sL " https://api.github.com/repos/$GITHUB_REPO /$1 " -X " $2 " -d " $3 "
18
25
}
19
26
20
27
VERBOSE=0
36
43
GITHUB_PASSWORD=${args[$counter + 1]}
37
44
readed_counter=$[$readed_counter + 1]
38
45
elif [[ $i == ' --verbose' ]] || [[ $i == ' -v' ]]; then
39
- VERBOSE=1
46
+ VERBOSE=1
40
47
else
41
- GITHUB_REPO=$i
48
+ GITHUB_REPO=$i
42
49
fi
43
50
44
51
readed_counter=$[$readed_counter + 1]
@@ -49,16 +56,16 @@ if [ -z "$GITHUB_REPO" ]; then
49
56
read -p " Type your Github repository name (owner/repo_name): " GITHUB_REPO
50
57
fi
51
58
52
- if [ -z " $GITHUB_USERNAME " ]; then
59
+ if [ -z " $GITHUB_USERNAME " ] && [ -z $GITHUB_TOKEN ] ; then
53
60
read -p " Type your Github username: " GITHUB_USERNAME
54
61
fi
55
62
56
- if [ -z " $GITHUB_PASSWORD " ]; then
63
+ if [ -z " $GITHUB_PASSWORD " ] && [ -z $GITHUB_TOKEN ] ; then
57
64
read -p " Type your Github password (won't be shown): " -s GITHUB_PASSWORD
58
65
echo ;
59
66
fi
60
67
61
- if [ -z " $GITHUB_USERNAME " ] || [ -z " $GITHUB_REPO " ]; then
68
+ if [ -z " $GITHUB_USERNAME " ] || [ -z " $GITHUB_REPO " ] && [ -z $GITHUB_TOKEN ] ; then
62
69
>&2 echo " There are missing parameters !"
63
70
>&2 printf " $( getHelp) "
64
71
exit 1
@@ -102,7 +109,7 @@ Type: Improvement,84b6eb
102
109
Type: New feature,0052cc
103
110
Type: Sub-task,ededed'
104
111
105
- if [[ " $VERBOSE " == 1 ]]; then
112
+ if [[ " $VERBOSE " == 1 ]]; then
106
113
echo " Removing default labels"
107
114
fi
108
115
@@ -112,12 +119,12 @@ while read -r label; do
112
119
if [[ ! " $response " == * " Not Found" * ]]; then
113
120
echo " Error removing \" $label \" : $response "
114
121
fi
115
- elif [[ " $VERBOSE " == 1 ]]; then
122
+ elif [[ " $VERBOSE " == 1 ]]; then
116
123
echo " Label \" $label \" removed"
117
124
fi
118
125
done <<< " $REMOVE_DEFAULT_LABELS"
119
126
120
- if [[ " $VERBOSE " == 1 ]]; then
127
+ if [[ " $VERBOSE " == 1 ]]; then
121
128
echo " Creating new labels"
122
129
fi
123
130
@@ -130,7 +137,7 @@ while read -r label; do
130
137
if [[ ! " $response " == * " already_exists" * ]]; then
131
138
>&2 echo " Error on creating: $label_name , response: $response "
132
139
fi
133
- elif [[ " $VERBOSE " == 1 ]]; then
140
+ elif [[ " $VERBOSE " == 1 ]]; then
134
141
echo " Label \" $label_name \" created"
135
142
fi
136
143
done <<< " $LABELS"
0 commit comments