Last active
July 21, 2021 11:23
-
-
Save woehrl01/eba8e0e019b5fcd1f33d7986c78263ae to your computer and use it in GitHub Desktop.
GitHub Action Nuget restore configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This gist demonstrated how you can configure NuGet source without storing the credentials in plaintext on the disc | |
# We enable this by only storing references to environment variables into the NuGet configuration (%NUGET_USERNAME%) | |
name: Configure NuGet source on private GitHub package repository | |
jobs: | |
build: | |
env: | |
NUGET_USERNAME: ${{ secrets.NUGET_USERNAME }} #Needs to be the user associated with the personal access token (PAT) | |
NUGET_PATTOKEN: ${{ secrets.NUGET_PATTOKEN }} #PAT only needs the read:packages scope | |
NUGET_GITHUB_ORGANISATION: ${{ github.repository_owner }} #Name of the organization where the feed is stored | |
steps: | |
- run: | | |
if ! grep -q "github_$NUGET_GITHUB_ORGANISATION" ~/.nuget/NuGet/NuGet.Config; | |
then | |
dotnet nuget add source --username "%NUGET_USERNAME%" --password "%NUGET_PATTOKEN%" \ | |
--store-password-in-clear-text --name "github_$NUGET_GITHUB_ORGANISATION" \ | |
"https://nuget.pkg.github.com/$NUGET_GITHUB_ORGANISATION/index.json"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment