Within the ci.yml I am packing the projects
- name: Create Client Package
run: dotnet pack ${{ env.CLIENT_NAME }} --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --output ${{ env.PUBLISH_PATH }}
- name: Create Model Package
run: dotnet pack ${{ env.MODEL_NAME }} --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --output ${{ env.PUBLISH_PATH }}
- name: Create NBS Package
run: dotnet pack ${{ env.NBS_NAME }} --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --output ${{ env.PUBLISH_PATH }}
- name: Upload NuGet Packages
uses: actions/upload-artifact@v3
if: ${{ matrix.language == 'csharp' && (github.event.pull_request.merged || github.event_name == 'workflow_dispatch') }}
with:
name: ${{ github.event.repository.name }}-nuget
path: ${{ env.NUGET_PATH }}/*.nupkg
How do I find these files created from the cd.yml file so I can push to the GitHub Packages?
- name: Download NuGet Packages from GitHub
uses: dawidd6/action-download-artifact@v2.13.0
with:
workflow: ci.yml
workflow_conclusion: success
name: ${{ github.event.repository.name }}-nuget
path: ${{ env.NUGET_PATH }}/output
search_artifacts: true
- name: Push NuGet Packages to GitHub Packages
run: dotnet nuget push ${{ env.PUBLISH_PATH }}/*.nupkg --source github --skip-duplicate --api-key ${{ secrets.ACTIONS_PAT }}
I tried packing the projects in the ci.yml file and reference their location using env.PUBLISH_PATH
When it is run the location does not exist.
Now using the upload/download of artifacts I am able to access the NuGet packages. But am unable to PUSH
the packages to the GitHub Packages.
I get an error of warn : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
I have tried the GITHUB_TOKEN and creating a PAT that has read/write/delete access to the packages. Any suggestions would be greatly appreciated.
This is what I ended up using for the cd.yml file
- name: Add GitHub Packages nuget source
run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.PACKAGES_PAT }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
# https://github.com/dawidd6/action-download-artifact
- name: Download NuGet Packages from GitHub
uses: dawidd6/action-download-artifact@v2.13.0
with:
workflow: ci.yml
workflow_conclusion: success
name: ${{ github.event.repository.name }}-nuget
path: ${{ env.NUGET_PATH }}/output
search_artifacts: true
- name: Push NuGet Packages to GitHub Packages
run: dotnet nuget push ${{ env.NUGET_PATH }}/output/*.nupkg --source github --skip-duplicate --api-key ${{ env.GITHUB_TOKEN }}
Used secret.PACKAGES_PAT
for the add source but used secrets.GITHUB_TOKEN
for the push function.