From 7e4abae4438b857787604dd38de046ece4a21416 Mon Sep 17 00:00:00 2001 From: Brian Cristante <33549821+brcrista@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:55:47 -0400 Subject: [PATCH] Pass the `token` input through on GHES (#427) * Pass the`token` input through on GHES * Update the description for `token` * Fix dist files * Update package-lock.json * Update README * Fix indent level in YAML snippet * secret names can't start with GITHUB_ --- README.md | 9 ++++++++- action.yml | 2 +- dist/setup/index.js | 2 +- package-lock.json | 4 ++-- src/install-python.ts | 4 ++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1e556d7..b4d5b44 100644 --- a/README.md +++ b/README.md @@ -364,7 +364,14 @@ If you are experiencing problems while configuring Python on your self-hosted ru `setup-python` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Python distributions, `setup-python` downloads distributions from [`actions/python-versions`](https://github.com/actions/python-versions) on github.com (outside of the appliance). These calls to `actions/python-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during download that read `##[error]API rate limit exceeded for...`. -To avoid hitting rate-limit problems, we recommend [setting up your own runner tool cache](https://docs.github.com/en/enterprise-server@2.22/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access#about-the-included-setup-actions-and-the-runner-tool-cache). +To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action: + +```yml +uses: actions/setup-python@v4 +with: + token: ${{ secrets.GH_DOTCOM_TOKEN }} + python-version: 3.11 +``` # License diff --git a/action.yml b/action.yml index 27474e2..e5d3d5b 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: architecture: description: 'The target architecture (x86, x64) of the Python interpreter.' token: - description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user. + description: The token used to authenticate when to fetching Python distributions from https://github.com/actions/python-versions. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. 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.' diff --git a/dist/setup/index.js b/dist/setup/index.js index 0d98b66..2b2504b 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -64432,7 +64432,7 @@ const tc = __importStar(__nccwpck_require__(7784)); const exec = __importStar(__nccwpck_require__(1514)); const utils_1 = __nccwpck_require__(1314); const TOKEN = core.getInput('token'); -const AUTH = !TOKEN || utils_1.isGhes() ? undefined : `token ${TOKEN}`; +const AUTH = !TOKEN ? undefined : `token ${TOKEN}`; const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main'; diff --git a/package-lock.json b/package-lock.json index 5354897..d009e43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "setup-python", - "version": "3.1.1", + "version": "4.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "setup-python", - "version": "3.1.1", + "version": "4.0.0", "license": "MIT", "dependencies": { "@actions/cache": "^2.0.2", diff --git a/src/install-python.ts b/src/install-python.ts index 397da0c..eeeb68f 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -3,10 +3,10 @@ import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; import * as exec from '@actions/exec'; import {ExecOptions} from '@actions/exec/lib/interfaces'; -import {IS_WINDOWS, IS_LINUX, isGhes} from './utils'; +import {IS_WINDOWS, IS_LINUX} from './utils'; const TOKEN = core.getInput('token'); -const AUTH = !TOKEN || isGhes() ? undefined : `token ${TOKEN}`; +const AUTH = !TOKEN ? undefined : `token ${TOKEN}`; const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main';