Skip to content

Only use github.token on github.com - #443

Merged
brcrista merged 7 commits into
actions:mainfrom
ChristopherHX:patch-1
Aug 30, 2022
Merged

Only use github.token on github.com#443
brcrista merged 7 commits into
actions:mainfrom
ChristopherHX:patch-1

Conversation

@ChristopherHX

@ChristopherHXChristopherHX commented Jun 27, 2022

Copy link
Copy Markdown
Contributor

Description:
This expression ${{ github.server_url == 'https://github.com' && github.token || '' }} evaluates to '' if called from GHES hosted elsewhere
You can still provide your token on both github.com and GHES
See docu https://docs.github.com/en/actions/learn-github-actions/contexts.

Related issue:
Needs PullRequest: #427
#229, without the need for a new input or breaking using the token input on GHES.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

This expression evaluates to `''` if called from GHES hosted elsewhere
You can still provide your token on both github.com and GHES
@ChristopherHX
ChristopherHX requested a review from a teamJune 27, 2022 08:25
@brcrista

Copy link
Copy Markdown
Contributor

Thanks for the suggestion! Let me try testing this against a GHES instance with #437 re-enabled.

@brcrista

Copy link
Copy Markdown
Contributor

Tested on a GHES instance (3.6.0) with this workflow:

name: CIon: [workflow_dispatch]jobs:
sample_build:
runs-on: [ self-hosted ]steps:
- name: "rate limit"run: | curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token $TOKEN" \ https://api.github.com/rate_limitenv:
TOKEN: ${{ secrets.GH_DOTCOM_TOKEN }}
- name: Clear the tool cacherun: rm -rf /Users/runner/hostedtoolcache/Python/
- name: Set up Pythonuses: brcrista/setup-python@patch-1with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}python-version: 3.9.12
- name: "rate limit"run: | curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token $TOKEN" \ https://api.github.com/rate_limitenv:
TOKEN: ${{ secrets.GH_DOTCOM_TOKEN }}

Confirmed that:

  1. The token is used when it is passed to setup-python
  2. Commented out the token so the input is using a default value => download succeeds

@brcrista

Copy link
Copy Markdown
Contributor

Also regression-tested the default case on github.com and made sure the download still works.

Comment threaddocs/advanced-usage.md Outdated
Comment threadaction.yml Outdated

@brcristabrcrista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is passing now; must have been an issue with one of the hosted images.

Thanks @ChristopherHX for your contribution!

@brcrista
brcrista merged commit 98c991d into actions:mainAug 30, 2022
@ChristopherHX
ChristopherHX deleted the patch-1 branch December 17, 2022 23:33
tdfacer pushed a commit to ifit/setup-python that referenced this pull request Oct 7, 2025
* 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
* Enshure blank result of expression and not false
* Revert "Revert "Pass the `token` input through on GHES (actions#427)" (actions#437)"
This reverts commit f05e25d.
* fix typo
* Add back the doc on the tool cache for self-hosted
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ChristopherHX@brcrista@vsafonkin@IvanZosimov@marko-zivic-93