From 0b992d8a43e7008af29fe58916e88166154121de Mon Sep 17 00:00:00 2001 From: Henrik Poulsen Date: Mon, 10 Jan 2022 10:47:30 +0100 Subject: [PATCH 1/2] Add support for adding a token on GHES to prevent rate limiting --- action.yml | 3 +++ dist/setup/index.js | 7 ++++++- src/install-python.ts | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index a1dd5b77f..2855adef6 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,9 @@ inputs: default: ${{ github.token }} cache-dependency-path: description: 'Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies.' + ghes_token: + description: Used to pull python distributions from actions/python-versions when using Github Enterprise. This should be a github.com read only access token + default: "" outputs: python-version: description: "The installed python version. Useful when given a version range as input." diff --git a/dist/setup/index.js b/dist/setup/index.js index 321877d9a..5551ef819 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -52264,7 +52264,12 @@ const tc = __importStar(__webpack_require__(533)); const exec = __importStar(__webpack_require__(986)); const utils_1 = __webpack_require__(163); const TOKEN = core.getInput('token'); -const AUTH = !TOKEN || utils_1.isGhes() ? undefined : `token ${TOKEN}`; +const GHES_TOKEN = core.getInput('ghes_token'); +const AUTH = utils_1.isGhes() + ? `token ${GHES_TOKEN}` + : TOKEN + ? `token ${TOKEN}` + : undefined; const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main'; diff --git a/src/install-python.ts b/src/install-python.ts index 397da0cb9..7aee61d55 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -6,7 +6,12 @@ import {ExecOptions} from '@actions/exec/lib/interfaces'; import {IS_WINDOWS, IS_LINUX, isGhes} from './utils'; const TOKEN = core.getInput('token'); -const AUTH = !TOKEN || isGhes() ? undefined : `token ${TOKEN}`; +const GHES_TOKEN = core.getInput('ghes_token'); +const AUTH = isGhes() + ? `token ${GHES_TOKEN}` + : TOKEN + ? `token ${TOKEN}` + : undefined; const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main'; From 06ce3b622f7bf413dfe4913dd55abbaba1245f14 Mon Sep 17 00:00:00 2001 From: Henrik Poulsen Date: Tue, 11 Jan 2022 14:34:27 +0100 Subject: [PATCH 2/2] Return undefined if GHES_TOKEN is not set when running on GHES --- dist/setup/index.js | 4 +++- src/install-python.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 5551ef819..c699e65d0 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -52266,7 +52266,9 @@ const utils_1 = __webpack_require__(163); const TOKEN = core.getInput('token'); const GHES_TOKEN = core.getInput('ghes_token'); const AUTH = utils_1.isGhes() - ? `token ${GHES_TOKEN}` + ? GHES_TOKEN + ? `token ${GHES_TOKEN}` + : undefined : TOKEN ? `token ${TOKEN}` : undefined; diff --git a/src/install-python.ts b/src/install-python.ts index 7aee61d55..44e9fa3b2 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -8,7 +8,9 @@ import {IS_WINDOWS, IS_LINUX, isGhes} from './utils'; const TOKEN = core.getInput('token'); const GHES_TOKEN = core.getInput('ghes_token'); const AUTH = isGhes() - ? `token ${GHES_TOKEN}` + ? GHES_TOKEN + ? `token ${GHES_TOKEN}` + : undefined : TOKEN ? `token ${TOKEN}` : undefined;