Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use github.token on github.com #443

Merged
merged 7 commits into from
Aug 30, 2022
Merged

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.

docs/advanced-usage.md Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
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!

Sign up for free to 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