From e6d4b8dcddcfc7624077300350a045a496201fe2 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Mon, 27 Jun 2022 10:16:03 +0200 Subject: [PATCH 1/5] Only use github.token on github.com This expression evaluates to `''` if called from GHES hosted elsewhere You can still provide your token on both github.com and GHES --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 27474e2aa..a6113b7b8 100644 --- a/action.yml +++ b/action.yml @@ -14,7 +14,7 @@ inputs: 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. - default: ${{ github.token }} + default: ${{ github.server_url == 'https://github.com' && 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.' outputs: From 0c05b355145781d935d0f10730f7ead6de09cf82 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Mon, 27 Jun 2022 10:53:22 +0200 Subject: [PATCH 2/5] Enshure blank result of expression and not false --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a6113b7b8..6b0224f4f 100644 --- a/action.yml +++ b/action.yml @@ -14,7 +14,7 @@ inputs: 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. - default: ${{ github.server_url == 'https://github.com' && github.token }} + default: ${{ github.server_url == 'https://github.com' && 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.' outputs: From 5ee239573ce8c441e757132190902a29c826ee8e Mon Sep 17 00:00:00 2001 From: Brian Cristante <33549821+brcrista@users.noreply.github.com> Date: Fri, 5 Aug 2022 14:42:32 -0400 Subject: [PATCH 3/5] Revert "Revert "Pass the `token` input through on GHES (#427)" (#437)" This reverts commit cf86e08a31433e1dc61981fa0301f2adc9606f46. --- action.yml | 2 +- dist/setup/index.js | 2 +- docs/advanced-usage.md | 9 ++++++++- src/install-python.ts | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 5ff5761f3..db51b02a0 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,7 @@ inputs: description: "Set this option if you want the action to check for the latest available version that satisfies the version spec." default: false 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.server_url == 'https://github.com' && 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 f77bae2db..0ae650d04 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -65190,7 +65190,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/docs/advanced-usage.md b/docs/advanced-usage.md index 024e8b1ec..4f15e371e 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -473,4 +473,11 @@ One quick way to grant access is to change the user and group of `/Users/runner/ `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 downloading that looks like: `##[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). \ No newline at end of file +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 +``` diff --git a/src/install-python.ts b/src/install-python.ts index 6e5c85188..aa6ab2d4d 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'; From 0bdcf94ac952bfcdd45f02ff5841b1deadb409eb Mon Sep 17 00:00:00 2001 From: Brian Cristante <33549821+brcrista@users.noreply.github.com> Date: Wed, 10 Aug 2022 13:50:56 -0400 Subject: [PATCH 4/5] fix typo --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index db51b02a0..b8bb06b39 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,7 @@ inputs: description: "Set this option if you want the action to check for the latest available version that satisfies the version spec." default: false token: - 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." + description: "The token used to authenticate when 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.server_url == 'https://github.com' && 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." From 0b45fd9900382d396c469426e14ae9a64da6c5df Mon Sep 17 00:00:00 2001 From: Brian Cristante <33549821+brcrista@users.noreply.github.com> Date: Wed, 10 Aug 2022 13:56:24 -0400 Subject: [PATCH 5/5] Add back the doc on the tool cache for self-hosted --- docs/advanced-usage.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 4f15e371e..9802fd776 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -481,3 +481,5 @@ with: token: ${{ secrets.GH_DOTCOM_TOKEN }} python-version: 3.11 ``` + +If the runner is not able to access github.com, any Python versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information. \ No newline at end of file