Skip to content

Conversation

@ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Jun 27, 2022

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 team June 27, 2022 08:25
@brcrista
Copy link
Contributor

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

@brcrista
Copy link
Contributor

brcrista commented Aug 5, 2022

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

name: CI on: [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_limit  env: TOKEN: ${{ secrets.GH_DOTCOM_TOKEN }} - name: Clear the tool cache run: rm -rf /Users/runner/hostedtoolcache/Python/ - name: Set up Python uses: brcrista/setup-python@patch-1 with: 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_limit  env: 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
Contributor

brcrista commented Aug 5, 2022

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

Copy link
Contributor

@brcrista brcrista left a comment

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:main Aug 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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants