Skip to content

Commit

Permalink
Fix logic of github_api to autodetect host
Browse files Browse the repository at this point in the history
  • Loading branch information
AliSoftware committed Sep 19, 2024
1 parent ed6ecaa commit 656a585
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/github_api
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# ENVIRONMENT VARIABLES:
# GITHUB_TOKEN: Required. The GitHub token to use for authentication.
# GH_HOST: Optional. The GitHub host to use. We'll figure out the host from `BUILDKITE_*` env vars if not set.
# GH_HOST: Optional. The GitHub host to use. We'll figure out the host from `BUILDKITE_REPO` env var if not set.
#
# Usage:
# github_api <endpoint> [curl-options]
Expand All @@ -23,8 +23,8 @@ shift

github_host=${GH_HOST:-}
if [[ -z "${github_host}" ]]; then
if [[ -n "${BUILDKITE_PULL_REQUEST_REPO:-}" ]]; then
github_host=$(echo "$BUILDKITE_PULL_REQUEST_REPO" | awk -F[/:] '{print $4}')
if [[ "${BUILDKITE_REPO:-}" =~ ^(https?://|git@)([^/:]+)[:/] ]]; then
github_host="${BASH_REMATCH[2]}"
else
github_host=github.com
fi
Expand Down

0 comments on commit 656a585

Please sign in to comment.