Skip to content

Commit 22ec85d

Browse files
Added better support for the automated stackbrew script on PR merges
1 parent 3f5fd50 commit 22ec85d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

generate-stackbrew-pr.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ else
1616
fi
1717
fi
1818

19+
if [[ "$COMMIT_MESSAGE" =~ Merge\ pull\ request\ \#([0-9]*) ]]; then
20+
21+
# This is a merge from a pull request
22+
PR_NUMBER="${BASH_REMATCH[1]}"
23+
COMMIT_MESSAGE="$(printf "%s" "$COMMIT_MESSAGE" | tail -n 1)"
24+
fi
25+
1926
IMAGES_FILE="library/node"
2027
REPO_NAME="official-images"
2128
ORIGIN_SLUG="$GITHUB_USERNAME/$REPO_NAME"
@@ -130,12 +137,18 @@ if updated; then
130137
if [ "$url" != "null" ]; then
131138
info "Pull request created at $url"
132139

140+
if [ ! -z "$PR_NUMBER" ]; then
141+
comment_endpoint="https://api.github.com/repos/$DOCKER_SLUG/issues/$PR_NUMBER/comments"
142+
else
143+
comment_endpoint="https://api.github.com/repos/$DOCKER_SLUG/commits/$COMMIT_ID/comments"
144+
fi
145+
133146
info "Creating Commit Comment"
134147
commit_response_payload="$(curl -H "$(auth_header)" \
135148
-s \
136149
-X POST \
137150
-d "$(comment_payload "$url")" \
138-
"https://api.github.com/repos/$DOCKER_SLUG/commits/$COMMIT_ID/comments")"
151+
"$comment_endpoint")"
139152

140153
if [ "$(echo "$commit_response_payload" | jq .message)" != "null" ]; then
141154
fatal "Error linking the pull request ($error_message)"

0 commit comments

Comments
 (0)