I have an organization in GitHub with Free plan. I created a private repository for this organization and GitHub action to build and push my nuget package to registry.
My GitHub action code is following:
name: nuget-publish
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- Package.core/**
pull_request:
branches: [ "main" ]
paths:
- Package.core/**
defaults:
run:
shell: pwsh
jobs:
build:
env:
PROJECT: './Package.core/src/Package.Core.SDK/Package.Core.SDK.csproj'
BUILD_CONFIG: 'Release'
name: Build Package
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'
- name: Build
run: dotnet build ${{ env.PROJECT }} --configuration ${{ env.BUILD_CONFIG }}
- name: Package
run: >
dotnet pack ${{ env.PROJECT }} --no-restore --no-build --configuration ${{ env.BUILD_CONFIG }}
--output .
- name: Publish
run: >
dotnet nuget push **/Package.Core.SDK.*.nupkg
-s 'https://nuget.pkg.github.com/<organization-name>/index.json'
-k ${{ secrets.GH_PAT }}
To create GH_PAT secret a followed next steps:
- For the account I created my organization from I created personal access token with the following permissions:
- For the repository I created new Repository Secret:
After running this Github action I’m getting the following error:
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.
error: Response status code does not
indicate success: 403 (Forbidden).