diff --git a/lib/main.js b/lib/main.js index 977fcf8..3db4fd4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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, @@ -26,6 +22,7 @@ export async function main( const auth = createAppAuth({ appId, privateKey, + request, }); const appAuthentication = await auth({ diff --git a/lib/post.js b/lib/post.js index bfbae77..f02d0e5 100644 --- a/lib/post.js +++ b/lib/post.js @@ -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"); diff --git a/lib/request.js b/lib/request.js new file mode 100644 index 0000000..729cc19 --- /dev/null +++ b/lib/request.js @@ -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", + }, +}); diff --git a/main.js b/main.js index eb480d4..9b269a1 100644 --- a/main.js +++ b/main.js @@ -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 '/'"); diff --git a/post.js b/post.js index 145bc7e..66e37eb 100644 --- a/post.js +++ b/post.js @@ -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,