-
I’m trying to push NuGet packages to a GitHub package feed but currently can’t restore GitHub NuGet packages during the build that were created from Actions in another repo:
NuGet auth token is set with
I also tried using the same token used when pushing the packages that are attempting to be restored here but it’s the same result. I’m assuming I need to modify NuGet.config so it has the credentials like:
However I thought that wouldn’t be required within the context of GitHub actions in the same org? If it is required, what’s the practical way of doing it? Configuring dotnet CLI for use with GitHub Packages suggest setting these but overlooks the fact that |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Hi @ghudik-cas,
The
Almost. If you’re using .NET Core 3.1 or above, you can create a
You can then set the You could also create a I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks @jcansdale. That helps. Why does it need to be an org level secret though? I thought that was only if you needed to not duplicate secrets between repos (just being used in one repo here). Also org level secrets require Admin I believe which most devs won’t have so it’s a bit more hassle to create having to route through an Admin. As I mentioned I had also tried replacing The restore is currently working (after populating nuget.config creds) but the push is failing; at the moment I’m using one token with read/write packages (and repo) for both the auth and restore as well as the push but the push result is For the time being I’ve removed
In any event the GH documentation around this area seems very lacking IMO but maybe I’m missing something. |
Beta Was this translation helpful? Give feedback.
-
You’re right, it doesn’t need to be an org level secret. I find doing it this way convenient for the
The access is a combination of the PAT scopes and the read/write access the PAT’s owner has to the associated repository. Could you check that the owner of the PAT has write access to the repository associated with the package?
Here are a few minor suggestions.
You can use the following to quieten down dotnet (I think this includes telemetry opt out).
Unfortunately this is ignored. All it will do is suppress the warning, which is misleading.
Could you let me know the name of the repository this is in so I can investigate further? You can send a message using this link: GitHub SupportThanks, |
Beta Was this translation helpful? Give feedback.
-
Small forgotten thing that wasn’t obvious to me from original error messages. Thanks for the help |
Beta Was this translation helpful? Give feedback.
-
I also found it a bit strange that it was hard to glean from the main documentation how this was supposed to be set up. I also had the requirement that I wanted to both read and write to both nuget.org and GH Packages. The solution that worked for me was to create a classic PAT with read/write access to packages for the orgs public repos. In the pipeline, rather than using a NuGet.Config file, I reconfigured the sources like this: - name: 'NuGet: Configure sources'
run: |
dotnet nuget remove source nuget.org
dotnet nuget add source -n nuget.org -u NUGETUSER -p ${{ secrets.NUGET_TOKEN }} --store-password-in-clear-text "https://api.nuget.org/v3/index.json"
dotnet nuget add source -n github -u GH_ORG -p ${{ secrets.NUGET_GH_TOKEN }} --store-password-in-clear-text "https://nuget.pkg.github.com/GH_ORG/index.json" This way the - name: 'Nuget: Push to GH Packages'
run: dotnet nuget push ./output/nuget/*.nupkg --source "github" --api-key ${{ secrets.NUGET_GH_TOKEN }}
- name: 'Nuget: Push release to nuget.org'
run: dotnet nuget push ./output/nuget/*.nupkg --source "nuget.org" --api-key ${{ secrets.NUGET_TOKEN }} In my case I also have condition for running each of those, but that's besides the point of this post. Hope this helps someone or that somebody from GitHub sees this and adds it to the docs. |
Beta Was this translation helpful? Give feedback.
Hi @ghudik-cas,
The
${{ secrets.GITHUB_TOKEN }}
token is scoped to the workflow repository. What you can do is create an org level secret containing a PAT with theread:packages
scope. You can then use something like${{ secrets.READ_PACKAGES_TOKEN }}
from your workflow.Almost. If you’re using .NET Core 3.1 or above, you can create a
nuget.config
(all lowercase) file at the base of your repository like: