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

Allows API URL override via environment variable to support GitHub Enterprise #24

Merged
merged 6 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-app-token",
"version": "1.3.0",
"version": "1.4.0",
"license": "MIT",
"files": [
"action.yml",
Expand Down
13 changes: 11 additions & 2 deletions src/fetch-installation-token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { context, getOctokit } from "@actions/github";
import { getOctokit } from "@actions/github";
import { createAppAuth } from "@octokit/auth-app";
import { request } from "@octokit/request";

export const fetchInstallationToken = async ({
appId,
Expand All @@ -12,7 +13,15 @@ export const fetchInstallationToken = async ({
privateKey: string;
repo: string;
}>): Promise<string> => {
const app = createAppAuth({ appId, privateKey });
const app = createAppAuth({
appId,
privateKey,
request: request.defaults({
// GITHUB_API_URL is part of GitHub Actions' built-in environment variables.
// See https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables.
baseUrl: process.env["GITHUB_API_URL"]
})
});
const authApp = await app({ type: "app" });
const octokit = getOctokit(authApp.token);
const {
Expand Down