Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Add github_url input defaulting to GITHUB_API_URL#43

Merged
tibdex merged 3 commits intotibdex:mainfrom
cliffchapmanrbx:faeture/add-server-url-input
Oct 16, 2022
Merged

Add github_url input defaulting to GITHUB_API_URL#43
tibdex merged 3 commits intotibdex:mainfrom
cliffchapmanrbx:faeture/add-server-url-input

Conversation

@cliffchapmanrbx
Copy link
Copy Markdown
Contributor

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.

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.
Copy link
Copy Markdown
Contributor

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 }}.

Copy link
Copy Markdown
Contributor Author

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);
Copy link
Copy Markdown
Contributor

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 }}.

Copy link
Copy Markdown
Contributor Author

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.

@tibdex
Copy link
Copy Markdown
Owner

tibdex commented Oct 16, 2022

Thanks 👍

@tibdex tibdex merged commit 22db619 into tibdex:main Oct 16, 2022
@cliffchapmanrbx cliffchapmanrbx deleted the faeture/add-server-url-input branch October 17, 2022 19:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for generating tokens for different servers

3 participants