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

fix(GHES): respect GITHUB_API_URL when creating installation access token #38

Merged
merged 1 commit into from
Aug 30, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// @ts-check

import core from "@actions/core";
import { createAppAuth } from "@octokit/auth-app";
import { request } from "@octokit/request";

/**
* @param {string} appId
* @param {string} privateKey
* @param {string} repository
* @param {core} core
* @param {createAppAuth} createAppAuth
* @param {request} request
* @param {import("@actions/core")} core
* @param {import("@octokit/auth-app").createAppAuth} createAppAuth
* @param {import("@octokit/request").request} request
*/
export async function main(
appId,
Expand All @@ -26,6 +22,7 @@ export async function main(
const auth = createAppAuth({
appId,
privateKey,
request,
});

const appAuthentication = await auth({
Expand Down
7 changes: 2 additions & 5 deletions lib/post.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// @ts-check

import core from "@actions/core";
import { request } from "@octokit/request";

/**
* @param {core} core
* @param {request} request
* @param {import("@actions/core")} core
* @param {import("@octokit/request").request} request
*/
export async function post(core, request) {
const token = core.getState("token");
Expand Down
8 changes: 8 additions & 0 deletions lib/request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { request } from "@octokit/request";

export default request.defaults({
baseUrl: process.env["GITHUB_API_URL"],
headers: {
"user-agent": "actions/create-github-app-token",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add the current version here with https://github.com/gr2m/semantic-release-plugin-update-version-in-files, but I'd do that in a separate pr.

},
});
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import core from "@actions/core";
import { createAppAuth } from "@octokit/auth-app";
import { request } from "@octokit/request";

import { main } from "./lib/main.js";
import request from "./lib/request.js";

if (!process.env.GITHUB_REPOSITORY) {
throw new Error("GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'");
Expand Down
2 changes: 1 addition & 1 deletion post.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

import core from "@actions/core";
import { request } from "@octokit/request";

import { post } from "./lib/post.js";
import request from "./lib/request.js";

post(
core,
Expand Down