@@ -20,6 +20,7 @@ IMAGES_FILE="library/node"
2020REPO_NAME=" official-images"
2121ORIGIN_SLUG=" $GITHUB_USERNAME /$REPO_NAME "
2222UPSTREAM_SLUG=" docker-library/$REPO_NAME "
23+ DOCKER_SLUG=" nodejs/docker-node"
2324gitpath=" $REPO_NAME "
2425
2526function updated() {
@@ -86,6 +87,14 @@ function pr_payload() {
8687 }'
8788}
8889
90+ function comment_payload() {
91+ local pr_url
92+ pr_url=" $1 "
93+ echo ' {
94+ "body": "Created PR to the ' " $REPO_NAME " ' repo (' " $pr_url " ' )"
95+ }'
96+ }
97+
8998if updated; then
9099
91100 permission_check
@@ -108,16 +117,32 @@ if updated; then
108117 info " Pushing..."
109118 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"
110119
120+ cd - && rm -rf $gitpath
121+
111122 info " Creating Pull request"
112123 pr_response_payload=" $( curl -H " $( auth_header) " \
113124 -s \
114125 -X POST \
115126 -d " $( pr_payload) " \
116127 " https://api.github.com/repos/$UPSTREAM_SLUG /pulls" ) "
117128
118- url=" $( echo " $pr_response_payload " | jq .html_url) "
129+ url=" $( echo " $pr_response_payload " | jq -r .html_url) "
119130 if [ " $url " != " null" ]; then
120131 info " Pull request created at $url "
132+
133+ info " Creating Commit Comment"
134+ commit_response_payload=" $( curl -H " $( auth_header) " \
135+ -s \
136+ -X POST \
137+ -d " $( comment_payload " $url " ) " \
138+ " https://api.github.com/repos/$DOCKER_SLUG /commits/$COMMIT_ID /comments" ) "
139+
140+ if [ " $( echo " $commit_response_payload " | jq .message) " != " null" ]; then
141+ fatal " Error linking the pull request ($error_message )"
142+ else
143+ comment_url=" $( echo " $commit_response_payload " | jq -r .html_url) "
144+ info " Created comment at $comment_url "
145+ fi
121146 else
122147 error_message=$( echo " $pr_response_payload " | jq .message)
123148 fatal " Error creating pull request ($error_message )"
0 commit comments