Improve GITHUB_API_URL default value handling (#2031)

* Improve GITHUB_API_URL default value handling

GitHub Actions [already has](https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables) `GITHUB_API_URL` environment variable which contains GitHub API URL. We should be smart about overriding it and, if it exist and already has value, we should not override it.

* Strip slash from GITHUB_API_URL

* Update linter.sh

* Update linter.sh

* make shfmt happy

Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
Tomas Dabasinskas 2021-10-04 17:53:43 +03:00 committed by GitHub
parent 572f93466a
commit 192b06392a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,10 +64,18 @@ source /action/lib/functions/worker.sh # Source the function script(s)
###########
# GLOBALS #
###########
# GitHub API root url
if [ -n "$GITHUB_CUSTOM_API_URL" ]; then
GITHUB_API_URL="${GITHUB_CUSTOM_API_URL}"
elif [ -z "$GITHUB_API_URL" ]; then
GITHUB_API_URL="https://api.github.com"
fi
# Remove trailing slash if present
GITHUB_API_URL="${GITHUB_API_URL%/}"
# Default Vars
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter rules directory
GITHUB_API_URL="${GITHUB_CUSTOM_API_URL:-"https://api.github.com"}" # GitHub API root url
VERSION_FILE='/action/lib/functions/linterVersions.txt' # File to store linter versions
export VERSION_FILE # Workaround SC2034