Summary
Exchanges a GitHub Actions OIDC identity token for a NuGet API key using the specified token service URL and audience.
Requires permissions: id-token: write in the GitHub Actions workflow.
OIDC tokens and the returned API key are automatically masked in the build log.
Syntax
public Task<string> NuGetLogin(GitHubNuGetLoginSettings settings, CancellationToken cancellationToken = default(CancellationToken))
Examples
var loginSettings = new GitHubNuGetLoginSettings(
userName: "myorg",
tokenServiceUrl: "https://www.nuget.org/api/v2/token",
audience: "https://www.nuget.org");
var apiKey = await GitHubActions.Commands.NuGetLogin(loginSettings);
var settings = new DotNetNuGetPushSettings
{
ApiKey = apiKey,
Source = EnvironmentVariable("NUGET_API_URL")
};
foreach (var packageFilePath in GetFiles("./*.nupkg"))
{
DotNetNuGetPush(packageFilePath, settings);
}
Parameters
| Name |
Type |
Description |
| settings |
GitHubNuGetLoginSettings |
The user name, token service URL, and OIDC audience. |
| cancellationToken |
CancellationToken |
The cancellation token. |
Return Value
| Type |
Description |
| Task<string> |
The NuGet API key. |