@@ -20,6 +20,7 @@ IMAGES_FILE="library/node"
20
20
REPO_NAME=" official-images"
21
21
ORIGIN_SLUG=" $GITHUB_USERNAME /$REPO_NAME "
22
22
UPSTREAM_SLUG=" docker-library/$REPO_NAME "
23
+ DOCKER_SLUG=" nodejs/docker-node"
23
24
gitpath=" $REPO_NAME "
24
25
25
26
function updated() {
@@ -86,6 +87,14 @@ function pr_payload() {
86
87
}'
87
88
}
88
89
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
+
89
98
if updated; then
90
99
91
100
permission_check
@@ -108,16 +117,32 @@ if updated; then
108
117
info " Pushing..."
109
118
git push
" https://$GITHUB_API_TOKEN :[email protected] /$ORIGIN_SLUG .git" -f
" $BRANCH_NAME " 2> /dev/null
|| fatal
" Error pushing the updated stackbrew"
110
119
120
+ cd - && rm -rf $gitpath
121
+
111
122
info " Creating Pull request"
112
123
pr_response_payload=" $( curl -H " $( auth_header) " \
113
124
-s \
114
125
-X POST \
115
126
-d " $( pr_payload) " \
116
127
" https://api.github.com/repos/$UPSTREAM_SLUG /pulls" ) "
117
128
118
- url=" $( echo " $pr_response_payload " | jq .html_url) "
129
+ url=" $( echo " $pr_response_payload " | jq -r .html_url) "
119
130
if [ " $url " != " null" ]; then
120
131
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
121
146
else
122
147
error_message=$( echo " $pr_response_payload " | jq .message)
123
148
fatal " Error creating pull request ($error_message )"
0 commit comments