From ede6c158812854da7c63aa6635138d168de14bea Mon Sep 17 00:00:00 2001 From: 7Hazard Date: Wed, 30 Aug 2023 01:13:34 +0200 Subject: [PATCH] feat: add GitHub Enterprise Server (GHES) support (#36) This adds support for this action to be used in GitHub Enterprise Server. It sends request to the base url extracted from [GITHUB_API_URL](https://docs.github.com/en/enterprise-server@3.10/actions/learn-github-actions/variables#default-environment-variables). --------- Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> --- lib/post.js | 2 +- main.js | 19 +++++++++++++------ post.js | 15 +++++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/post.js b/lib/post.js index a0efe15..bfbae77 100644 --- a/lib/post.js +++ b/lib/post.js @@ -11,7 +11,7 @@ export async function post(core, request) { const token = core.getState("token"); if (!token) return; - + await request("DELETE /installation/token", { headers: { authorization: `token ${token}`, diff --git a/main.js b/main.js index 02ffcc2..eb480d4 100644 --- a/main.js +++ b/main.js @@ -15,9 +15,16 @@ const privateKey = core.getInput("private_key"); const repository = process.env.GITHUB_REPOSITORY; -main(appId, privateKey, repository, core, createAppAuth, request).catch( - (error) => { - console.error(error); - core.setFailed(error.message); - } -); +main( + appId, + privateKey, + repository, + core, + createAppAuth, + request.defaults({ + baseUrl: process.env["GITHUB_API_URL"], + }) +).catch((error) => { + console.error(error); + core.setFailed(error.message); +}); diff --git a/post.js b/post.js index 0e34a59..145bc7e 100644 --- a/post.js +++ b/post.js @@ -5,9 +5,12 @@ import { request } from "@octokit/request"; import { post } from "./lib/post.js"; -post(core, request).catch( - (error) => { - console.error(error); - core.setFailed(error.message); - } -); +post( + core, + request.defaults({ + baseUrl: process.env["GITHUB_API_URL"], + }) +).catch((error) => { + console.error(error); + core.setFailed(error.message); +});