Skip to content

Act sends GHE token from gh to github.com causing 401 #6077

@Cohen-Carlisle

Description

@Cohen-Carlisle

Bug report info

I don't think it's relevant and it's stuck on my work computer. I can provide if necessary.

Command used with act

act

Describe issue

With gh installed and authenticated to a GHE instance with a custom host, act pulls the token without checking if it is for the correct host. This results in sudden 401s and left me quite stumped. Doing a gh auth logout or a gh auth login -h github.com fixes the issue by either omitting the token (allowing public pull to succeed instead of sending a bad token to the wrong host) or returning the github.com token as the default, respectively. However, a code fix could be implemented, I believe at

cmd := exec.CommandContext(ctx, path, "auth", "token")
to retrieve only the token for the correct host.

Link to GitHub repository

No response

Workflow content

name: Example

on:
  workflow_dispatch:

jobs:
  action:
    runs-on: ubuntu-latest
  steps:
    - name: Setup Node.js
      uses: actions/setup-node@v4

Relevant log output

git clone 'https://github.com/actions/setup-node' # ref=v4
authentication required: Invalid username or token. Password authentication is not supported for Git operations.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions