Skip to content

Commit

Permalink
Upgrade the NuGet package.
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Feb 2, 2024
1 parent 57bc07e commit 0fdb7d9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Pathological.Globbing" Version="8.0.0" />
<PackageVersion Include="Octokit.NET.SDK" Version="0.0.4" />
<PackageVersion Include="GitHub.Octokit.SDK" Version="0.0.6" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Actions.Octokit/Actions.Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Octokit.NET.SDK" />
<PackageReference Include="GitHub.Octokit.SDK" />
<PackageReference Include="Microsoft.SourceLink.GitHub">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/Actions.Octokit/GitHubClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static GitHubClient Create(string token)
ArgumentException.ThrowIfNullOrWhiteSpace(token);

var request = RequestAdapter.Create(
new TokenAuthenticationProvider("Octokit.Gen", token));
new TokenAuthenticationProvider("GitHub.Actions.Octokit", token));

return new GitHubClient(request);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Actions.Octokit/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
global using Actions.Octokit.Serialization;

global using GitHub;
global using GitHub.Authentication;
global using GitHub.Client;
global using GitHub.Octokit.Authentication;
global using GitHub.Octokit.Client;

global using Microsoft.Extensions.DependencyInjection;

Expand Down
2 changes: 2 additions & 0 deletions src/Actions.Octokit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ To use the `GitHubClient` in your .NET project, register the services with an `I

```csharp
using Microsoft.Extensions.DependencyInjection;
using GitHub;
using Actions.Octokit;
using Actions.Octokit.Extensions;

Expand All @@ -34,6 +35,7 @@ using var provider = new ServiceCollection()
// The client relies on the value from ${{ secrets.GITHUB_TOKEN }}
var client = provider.GetRequiredService<GitHubClient>();

// Call GitHub REST API /repos/octokit/rest.js/pulls/123
var pullRequest = client.Repos["octokit"]["rest.js"].Pulls[123].GetAsync();

Console.WriteLine(pullRequest.Title);
Expand Down
28 changes: 28 additions & 0 deletions tests/Actions.Octokit.Tests/GitHubClientTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) David Pine. All rights reserved.
// Licensed under the MIT License.

namespace Actions.Octokit.Tests;

public class GitHubClientTests
{
[Fact]
public async Task GitHubClientGetsFirstPullRequestTest()
{
var token = Environment.GetEnvironmentVariable("GITHUB_TOKEN");

if (token is null)
{
return; // Skip the test if the token isn't available.
}

var client = GitHubClientFactory.Create(token);

var owner = "IEvangelist";
var repo = "dotnet-github-actions-sdk";
var pullNumber = 1;

var firstPullRequest = await client.Repos[owner][repo].Pulls[pullNumber].GetAsync();

Assert.NotNull(firstPullRequest);
}
}

0 comments on commit 0fdb7d9

Please sign in to comment.