@@ -14,7 +14,14 @@ Usage:
1414}
1515
1616function 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 "
1825}
1926
2027VERBOSE=0
3643 GITHUB_PASSWORD=${args[$counter + 1]}
3744 readed_counter=$[$readed_counter + 1]
3845 elif [[ $i == ' --verbose' ]] || [[ $i == ' -v' ]]; then
39- VERBOSE=1
46+ VERBOSE=1
4047 else
41- GITHUB_REPO=$i
48+ GITHUB_REPO=$i
4249 fi
4350
4451 readed_counter=$[$readed_counter + 1]
@@ -49,16 +56,16 @@ if [ -z "$GITHUB_REPO" ]; then
4956 read -p " Type your Github repository name (owner/repo_name): " GITHUB_REPO
5057fi
5158
52- if [ -z " $GITHUB_USERNAME " ]; then
59+ if [ -z " $GITHUB_USERNAME " ] && [ -z $GITHUB_TOKEN ] ; then
5360 read -p " Type your Github username: " GITHUB_USERNAME
5461fi
5562
56- if [ -z " $GITHUB_PASSWORD " ]; then
63+ if [ -z " $GITHUB_PASSWORD " ] && [ -z $GITHUB_TOKEN ] ; then
5764 read -p " Type your Github password (won't be shown): " -s GITHUB_PASSWORD
5865 echo ;
5966fi
6067
61- if [ -z " $GITHUB_USERNAME " ] || [ -z " $GITHUB_REPO " ]; then
68+ if [ -z " $GITHUB_USERNAME " ] || [ -z " $GITHUB_REPO " ] && [ -z $GITHUB_TOKEN ] ; then
6269 >&2 echo " There are missing parameters !"
6370 >&2 printf " $( getHelp) "
6471 exit 1
@@ -102,7 +109,7 @@ Type: Improvement,84b6eb
102109Type: New feature,0052cc
103110Type: Sub-task,ededed'
104111
105- if [[ " $VERBOSE " == 1 ]]; then
112+ if [[ " $VERBOSE " == 1 ]]; then
106113 echo " Removing default labels"
107114fi
108115
@@ -112,12 +119,12 @@ while read -r label; do
112119 if [[ ! " $response " == * " Not Found" * ]]; then
113120 echo " Error removing \" $label \" : $response "
114121 fi
115- elif [[ " $VERBOSE " == 1 ]]; then
122+ elif [[ " $VERBOSE " == 1 ]]; then
116123 echo " Label \" $label \" removed"
117124 fi
118125done <<< " $REMOVE_DEFAULT_LABELS"
119126
120- if [[ " $VERBOSE " == 1 ]]; then
127+ if [[ " $VERBOSE " == 1 ]]; then
121128 echo " Creating new labels"
122129fi
123130
@@ -130,7 +137,7 @@ while read -r label; do
130137 if [[ ! " $response " == * " already_exists" * ]]; then
131138 >&2 echo " Error on creating: $label_name , response: $response "
132139 fi
133- elif [[ " $VERBOSE " == 1 ]]; then
140+ elif [[ " $VERBOSE " == 1 ]]; then
134141 echo " Label \" $label_name \" created"
135142 fi
136143done <<< " $LABELS"
0 commit comments