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
Add github_url input defaulting to GITHUB_API_URL #43
Add github_url input defaulting to GITHUB_API_URL #43
Conversation
@@ -14,6 +14,8 @@ inputs: | |||
description: The full name of the repository for which the token will be requested (defaults to the current repository). | |||
permissions: | |||
description: The JSON-stringified permissions granted to the token (defaults to all the GitHub app permissions, see https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app). | |||
github_url: | |||
description: The API URL of the GitHub server, such as https://api.github.com. Defaults to the environment variable GITHUB_API_URL, see https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding default: ${{ github.api_url }}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other inputs aren't written that way so I was sticking with the same pattern. I'm open to using this if the repo maintainer would prefer it.
src/index.ts
Outdated
const githubUrlInput = getInput("github_url"); | ||
const baseUrl = githubUrlInput | ||
? new URL(githubUrlInput) | ||
: new URL(env.GITHUB_API_URL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is unnecessary if you have a default set to ${{ github.api_url }}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same deal, mostly duplicating the existing pattern in the code instead of introducing a new one. I'm also open to changing it around if the maintainer would prefer.
Thanks 👍 |
Resolves #42
This adds a
github_url
parameter to the inputs so the baseUrl parameter for Octokit can be overridden. Currently it defaults to the GitHub Actions-supplied environment variable that contains the API URL for the local GitHub server. This env var cannot be overridden through any other means because it's managed by GitHub Actions.The input defaults to the same env var, so existing users are unaffected and this should not require a major version bump.
I added the round-trip through the URL class to get some minimal URL validation for free. I'm negotiable on whether this is considered valuable or it would be better to just treat it as a raw string instead, up to you.