Skip to content

Commit

Permalink
Fail if GitHub PR creation fails
Browse files Browse the repository at this point in the history
GitHub pull request creation can fail for various reasons [1], and
should return a 4XX code if it does.

Previously the response code was ignored (the default behaviour of
curl), so PR creation could silently fail. This change adds the curl
--fail argument, as is used for Gitlab.

[1] https://docs.github.com/en/free-pro-team@latest/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request--status-codes
  • Loading branch information
markgoddard committed Sep 27, 2023
1 parent 3632586 commit deba199
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ function github_pull_request {
--user "${KAYOBE_AUTOMATION_PR_GITHUB_USER}:${KAYOBE_AUTOMATION_PR_AUTH_TOKEN}" \
--header "Accept: application/vnd.github.v3+json" \
--header "Content-Type: application/json" \
--fail \
--data "${body}" | jq "."

log_info "Pull request created sucessfully"
Expand Down

0 comments on commit deba199

Please sign in to comment.