From d9376dacd30fd38f49238586cd2e9295a8307f4c Mon Sep 17 00:00:00 2001 From: David Saltares Date: Sun, 8 May 2022 17:44:07 +0300 Subject: [PATCH] feat: 37 - add support for Github Enterprise (#46) --- README.md | 4 ++++ action.yaml | 3 +++ dist/index.js | 3 ++- index.ts | 4 +++- tsconfig.json | 1 - 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69a8a2f..887edb0 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ Target file path. Only supports paths to subdirectories of the GitHub Actions wo Boolean indicating if `file` is to be interpreted as regular expression. Defaults to `false`. +### `octokitBaseUrl` + +The Github API base URL. Useful if you are using Github Enterprise. + ## Outputs ### `version` diff --git a/action.yaml b/action.yaml index 3f113fe..1afb4ed 100644 --- a/action.yaml +++ b/action.yaml @@ -25,6 +25,9 @@ inputs: type: boolean required: false default: false + octokitBaseUrl: + description: 'The Github API base URL. Useful if you are using Github Enterprise.' + required: false runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 7af81eb..b0c2a9d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12627,7 +12627,8 @@ var main = async () => { const file = core.getInput("file", { required: true }); const usesRegex = core.getBooleanInput("regex", { required: false }); const target = inputTarget === "" ? file : inputTarget; - const octokit = github.getOctokit(token); + const baseUrl = core.getInput("octokitBaseUrl", { required: false }) || void 0; + const octokit = github.getOctokit(token, { baseUrl }); const release = await getRelease(octokit, { owner, repo, version }); const assetFilterFn = usesRegex ? filterByRegex(file) : filterByFileName(file); const assets = release.data.assets.filter(assetFilterFn); diff --git a/index.ts b/index.ts index 7662d62..9840fd2 100644 --- a/index.ts +++ b/index.ts @@ -136,8 +136,10 @@ const main = async (): Promise => { const file = core.getInput('file', { required: true }); const usesRegex = core.getBooleanInput('regex', { required: false }); const target = inputTarget === '' ? file : inputTarget; + const baseUrl = + core.getInput('octokitBaseUrl', { required: false }) || undefined; - const octokit = github.getOctokit(token); + const octokit = github.getOctokit(token, { baseUrl }); const release = await getRelease(octokit, { owner, repo, version }); const assetFilterFn = usesRegex diff --git a/tsconfig.json b/tsconfig.json index 1a0c5ad..ed41542 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,6 @@ "alwaysStrict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "exactOptionalPropertyTypes": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true,