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

"Could not authenticate against github.com" #241

Closed
Jean85 opened this issue Feb 6, 2023 · 2 comments
Closed

"Could not authenticate against github.com" #241

Jean85 opened this issue Feb 6, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Jean85
Copy link
Contributor

Jean85 commented Feb 6, 2023

Description

I'm getting intermittent Could not authenticate against github.com errors in my CI, and I can't pinpoint the problem.

Steps to reproduce

See https://github.com/facile-it/paraunit/actions/runs/4105982330/jobs/7083607877
From this PR: facile-it/paraunit#183

Expected behavior

No issues

Screenshots or output

https://github.com/facile-it/paraunit/actions/runs/4105982330/jobs/7083607877#step:5:95

Environment details

It seems to happen for Tests CI jobs of that project, which are defined like this: https://github.com/facile-it/paraunit/blob/1c5414f0d9b4c67bafe0e05f40dcf9cf83ec20d1/.github/workflows/tests.yaml#L10

Additional context

The linked PR is very removed from the main branch (new major in the works). But the CI definition is very close, I just dropped older PHP versions:

I just rerun on the main branch and it works: https://github.com/facile-it/paraunit/actions/runs/4106204844 (failure on Windows is unrelated)

Is it possible that the failure is due to the usage of some additional repositories? I need them to pull some PRs as a dependency patch: https://github.com/facile-it/paraunit/blob/c6a6dc03c48b682ef7060ca218538e2c689edf44/composer.json#L58-L67

@Jean85 Jean85 added the bug Something isn't working label Feb 6, 2023
@ramsey
Copy link
Owner

ramsey commented Feb 6, 2023

I've run into this issue when running builds for projects that require private packages, but I've never seen it when using only public packages.

Here's how I solved it for the private packages, and maybe this will help in your case?

Add the following environment variable to your GitHub Actions workflow file. This can be outside the jobs, in which case it will apply to all jobs, or you can set the env var at any step in your jobs to limit it.

env:
   COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.PRIVATE_REPO_ACCESS }}"}}'

I called the secret PRIVATE_REPO_ACCESS, but you can name it whatever you want. It's a GitHub personal access token that has permission to read repos.

@Jean85
Copy link
Contributor Author

Jean85 commented Feb 7, 2023

You're right, that fixes it, thank you!

I'll file a PR to improve the README in this regard.

Jean85 added a commit to Jean85/composer-install that referenced this issue Feb 7, 2023
@ramsey ramsey closed this as completed Feb 7, 2023
batbattur added a commit to iFixit/php-ds-polyfill that referenced this issue Apr 14, 2023
The GITHUB_TOKEN  has only read access for
pull requests from
public forked repositories. See the error from ramsey/composer-install#241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants