Skip to content

Commit

Permalink
Don't fetch base branch if it's already set
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Aug 2, 2023
1 parent faf233c commit 9fa907c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ci/scripts/github/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ function update_conda_env() {
print_env_vars

function fetch_base_branch() {
rapids-logger "Retrieving base branch from GitHub API"
[[ -n "$GH_TOKEN" ]] && CURL_HEADERS=('-H' "Authorization: token ${GH_TOKEN}")
RESP=$(
curl -s \
-H "Accept: application/vnd.github.v3+json" \
"${CURL_HEADERS[@]}" \
"${GITHUB_API_URL}/repos/${ORG_NAME}/${REPO_NAME}/pulls/${PR_NUM}"
)

BASE_BRANCH=$(echo "${RESP}" | jq -r '.base.ref')
if [[ "${BASE_BRANCH}" == "" ]]; then
rapids-logger "Retrieving base branch from GitHub API"
[[ -n "$GH_TOKEN" ]] && CURL_HEADERS=('-H' "Authorization: token ${GH_TOKEN}")
RESP=$(
curl -s \
-H "Accept: application/vnd.github.v3+json" \
"${CURL_HEADERS[@]}" \
"${GITHUB_API_URL}/repos/${ORG_NAME}/${REPO_NAME}/pulls/${PR_NUM}"
)

BASE_BRANCH=$(echo "${RESP}" | jq -r '.base.ref')
fi

# Change target is the branch name we are merging into but due to the weird way jenkins does
# the checkout it isn't recognized by git without the origin/ prefix
Expand Down

0 comments on commit 9fa907c

Please sign in to comment.