Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve GITHUB_API_URL default value handling #2031

Merged
merged 6 commits into from
Oct 4, 2021
Merged

Improve GITHUB_API_URL default value handling #2031

merged 6 commits into from
Oct 4, 2021

Conversation

tdabasinskas
Copy link
Contributor

@tdabasinskas tdabasinskas commented Oct 4, 2021

GitHub Actions already has GITHUB_API_URL environment variable which contains GitHub API URL. We should be smart about overriding it and, if it exists and already has value, we should not override it.

In addition, we should strip the last trailing slash (if it exists) from GITHUB_API_URL, as API calls already append the slash.

This change allows running the action on GitHub Enterprise without the need to explicitly set GITHUB_CUSTOM_API_URL.

Proposed Changes

  1. If GITHUB_CUSTOM_API_URL exists, use its value as API URL
  2. If GITHUB_CUSTOM_API_URL does not exist, but GITHUB_API_URL is already set, use its value as API URL
  3. If neither GITHUB_CUSTOM_API_URL nor GITHUB_API_URL is set, use https://api.github.com as API URL
  4. Trailing slash is always trimmed from GITHUB_API_URL.

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants