33set -e
44. functions.sh
55
6- if [ -z " $1 " ]; then
7- COMMIT_ID=" $TRAVIS_COMMIT "
8- COMMIT_MESSAGE=" $TRAVIS_COMMIT_MESSAGE "
9- BRANCH_NAME=" travis-$TRAVIS_BUILD_ID "
6+ if [ -z " ${1} " ]; then
7+ COMMIT_ID=" ${ TRAVIS_COMMIT} "
8+ COMMIT_MESSAGE=" ${ TRAVIS_COMMIT_MESSAGE} "
9+ BRANCH_NAME=" travis-${ TRAVIS_BUILD_ID} "
1010 GITHUB_USERNAME=" nodejs-github-bot"
1111else
12- COMMIT_ID=" $1 "
13- COMMIT_MESSAGE=" $( git show -s --format=%B " $1 " ) "
12+ COMMIT_ID=" ${1} "
13+ COMMIT_MESSAGE=" $( git show -s --format=%B " ${COMMIT_ID} " ) "
1414 BRANCH_NAME=" travis-$( date +%s) "
1515 if [[ " $( git remote get-url origin) " =~ github.com/([^/]* )/docker-node.git ]]; then
1616 GITHUB_USERNAME=" ${BASH_REMATCH[1]} "
@@ -41,33 +41,33 @@ function updated() {
4141 )"
4242 images_changed=$( git diff --name-only " ${COMMIT_ID} " .." ${COMMIT_ID} " ~1 " ${versions[@]} " )
4343
44- if [ -z " $images_changed " ]; then
44+ if [ -z " ${ images_changed} " ]; then
4545 return 1
4646 fi
4747 return 0
4848}
4949
5050function auth_header() {
51- echo " Authorization: token $GITHUB_API_TOKEN "
51+ echo " Authorization: token ${ GITHUB_API_TOKEN} "
5252}
5353
5454function permission_check() {
55- if [ -z " $GITHUB_API_TOKEN " ]; then
55+ if [ -z " ${ GITHUB_API_TOKEN} " ]; then
5656 fatal " Environment variable \$ GITHUB_API_TOKEN is missing or empty"
5757 fi
5858
5959 auth=" $( curl -H " $( auth_header) " \
6060 -s \
6161 " https://api.github.com" ) "
6262
63- if [ " $( echo " $auth " | jq -r .message) " = " Bad credentials" ]; then
63+ if [ " $( echo " ${ auth} " | jq -r .message) " = " Bad credentials" ]; then
6464 fatal " Authentication Failed! Invalid \$ GITHUB_API_TOKEN"
6565 fi
6666
6767 auth=" $( curl -H " $( auth_header) " \
6868 -s \
6969 " https://api.github.com/repos/${ORIGIN_SLUG} /collaborators/${GITHUB_USERNAME} /permission" ) "
70- if [ " $( echo " $auth " | jq -r .message) " != " null" ]; then
70+ if [ " $( echo " ${ auth} " | jq -r .message) " != " null" ]; then
7171 fatal " \$ GITHUB_API_TOKEN can't push to https://github.com/${ORIGIN_SLUG} .git"
7272 fi
7373}
@@ -98,7 +98,7 @@ function pr_payload() {
9898
9999function comment_payload() {
100100 local pr_url
101- pr_url=" $1 "
101+ pr_url=" ${1} "
102102 echo " {
103103 'body': 'Created PR to the ${REPO_NAME} repo (${pr_url} )'
104104 }"
@@ -116,7 +116,7 @@ if updated; then
116116
117117 stackbrew=" $( ./generate-stackbrew-library.sh) "
118118
119- cd $gitpath
119+ cd ${ gitpath}
120120
121121 echo " ${stackbrew} " > " ${IMAGES_FILE} "
122122 git checkout -b " ${BRANCH_NAME} "
@@ -126,7 +126,7 @@ if updated; then
126126 info " Pushing..."
127127 git push " https://${GITHUB_API_TOKEN} :x-oauth-basic@github.com/${ORIGIN_SLUG} .git" -f " ${BRANCH_NAME} " 2> /dev/null || fatal " Error pushing the updated stackbrew"
128128
129- cd - && rm -rf $gitpath
129+ cd - && rm -rf ${ gitpath}
130130
131131 info " Creating Pull request"
132132 pr_response_payload=" $( curl -H " $( auth_header) " \
@@ -136,8 +136,8 @@ if updated; then
136136 " https://api.github.com/repos/${UPSTREAM_SLUG} /pulls" ) "
137137
138138 url=" $( echo " ${pr_response_payload} " | jq -r .html_url) "
139- if [ " $url " != " null" ]; then
140- info " Pull request created at $url "
139+ if [ " ${ url} " != " null" ]; then
140+ info " Pull request created at ${ url} "
141141
142142 if [ ! -z " ${PR_NUMBER} " ]; then
143143 comment_endpoint=" https://api.github.com/repos/${DOCKER_SLUG} /issues/${PR_NUMBER} /comments"
@@ -149,8 +149,8 @@ if updated; then
149149 commit_response_payload=" $( curl -H " $( auth_header) " \
150150 -s \
151151 -X POST \
152- -d " $( comment_payload " $url " ) " \
153- " $comment_endpoint " ) "
152+ -d " $( comment_payload " ${ url} " ) " \
153+ " ${ comment_endpoint} " ) "
154154
155155 if [ " $( echo " ${commit_response_payload} " | jq -r .message) " != " null" ]; then
156156 fatal " Error linking the pull request (${error_message} )"
0 commit comments