C
C#15mo ago
Zarickan

❔ How to pull nuget packages from private Github registry when doing dotnet restore in Github action

Does anyone know how to run dotnet restore from a Github action on a project that uses nuget packages from a private Github repository? I am currently adding the appropriate package source to nuget.config using
dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/USERNAME/index.json"
dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/USERNAME/index.json"
However dotnet restore fails with the error:
/usr/share/dotnet/sdk/7.0.203/NuGet.targets(132,5): warning : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured. [/home/runner/work/path-to.sln]
/usr/share/dotnet/sdk/7.0.203/NuGet.targets(132,5): warning : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured. [/home/runner/work/path-to.sln]
3 Replies
Anton
Anton15mo ago
It tells you that the scoped might be configured wrong. I guess check the scopes before all else
Zarickan
Zarickan15mo ago
Scopes are fine, should have all the access it needs. I have used the same GitHub actions token to push nuget packages, and it has write access by default. Thinking it might be an issue with dotnet restore using only the url of the registry and not the credentials. When doing the nuget push the credentials are explicitly supplied directly to the command as opposed to here where they are in the nuget.config.
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.