Skip to content

Commit be9d9f1

Browse files
Update nuget.md (#133)
Refined GitHub Secrets section with the following changes: * Changed example repo to the DevOpsExamples repo where I have recently added 3 new GitHub actions that use secrets to authenticate with the Telerik NuGet server. * Added the `packageSource` section to the nunget config file snippet. This is important because the key of the package source needs to match the xml node for the packagesourceCredential. * Changed the packageSource name from `Telerik` to `TelerikFeed` to make the relationship between the packagesource key and the credentials key * Added an important note about how GitHub keeps the secret encrypted and masked, even after being copied into an environment variable. * Added an important warning about GitHub's restriction of allowing secrets to be used in GH actions that were invoked by pull-request event * Small refinements to language describing the example (e.g. "get" to "set")
1 parent c550017 commit be9d9f1

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

installation/nuget.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ A few things to double check to ensure correct setup:
168168

169169
#### GitHub Secrets
170170

171-
In some cases, [GitHub Secrets](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) are used to store credentials that you would later have to consume from the `nuget.config` file in order to connect to the Telerik feed.
171+
In some cases, [GitHub Secrets](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) are used to store credentials that you would later have to consume from the `nuget.config` file in order to connect to the Telerik feed in your GitHub Actions workflows.
172172

173-
A way to pass them along is to mark them as environment variables. You can find an example in the [MediaFileManager repo by Lance McCarthy](https://github.com/LanceMcCarthy/MediaFileManager). Here follow the two relevant extracts.
173+
A way to pass them along is to mark them as environment variables. You can find an example in the [DevOpsExamples repo by Lance McCarthy](https://github.com/LanceMcCarthy/DevOpsExamples). Here follow the two relevant extracts.
174174

175-
>caption Example of getting GitHub Secrets for Telerik Login into Environment Variables
175+
>caption Example of setting GitHub Secrets into Environment Variables for Telerik Login
176176
177177
````YAML
178178
jobs:
@@ -183,23 +183,30 @@ jobs:
183183
TELERIK_USERNAME: ${ { secrets.MyTelerikAccountUsername } } # remove the space between the brackets
184184
TELERIK_PASSWORD: ${ { secrets.MyTelerikAccountPassword } } # remove the space between the brackets
185185

186-
187-
188186
````
187+
>tip Even though you are copying secrets into Environment Variables on the runner, Github Actions will continue to treat the values as protected string and mask the values in all output.
189188
190-
Then, read them as such in the `nuget.config` file, for example:
189+
Finally, you need a `nuget.config` file that lists the Telerik server in the `packageSources`, as well as an accompanying `packageSourceCredentials` that uses those named environment variables for the `Username` and `ClearTextPassword` keys.
191190

192-
>caption Example of reading the environment variables with the Telerik credentials in the nuget.config file
191+
>caption Example of Using Environment Variables in NuGet.config
193192
194193
````XML
195-
<packageSourceCredentials>
196-
<Telerik>
197-
<add key="Username" value="%TELERIK_USERNAME%" />
198-
<add key="ClearTextPassword" value="%TELERIK_PASSWORD%" />
199-
</Telerik>
200-
</packageSourceCredentials>
194+
<packageSources>
195+
<clear />
196+
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
197+
<add key="TelerikFeed" value="https://nuget.telerik.com/nuget" />
198+
</packageSources>
199+
<packageSourceCredentials>
200+
<TelerikFeed>
201+
<add key="Username" value="%TELERIK_USERNAME%" />
202+
<add key="ClearTextPassword" value="%TELERIK_PASSWORD%" />
203+
</TelerikFeed>
204+
</packageSourceCredentials>
201205
````
202206

207+
>warning GitHub does not allow secrets to be used in workflows that have been [triggered by a pull request event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows). In such a case, the runner will not be able to authenticate with the Telerik NuGet server and the job will expectedly fail.
208+
209+
Note:
203210

204211
## See Also
205212

0 commit comments

Comments
 (0)