Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ContribBot.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@

// Add the TypeScript Discord bot as an npm application using CommunityToolkit
// This will automatically run npm install and use the start script from package.json
var discordBot = builder.AddNpmApp("contrib-verifier", "../")
.WithNpmPackageInstallation()
.WithHttpEndpoint(targetPort: 3000, name: "webhook")
var discordBot = builder.AddJavaScriptApp("contrib-verifier", "../")
.WithHttpEndpoint(port: 3000, env: "PORT")
.WithExternalHttpEndpoints()
.WithEnvironment("CLIENT_ID", clientId)
.WithEnvironment("CLIENT_SECRET", clientSecret)
Expand All @@ -48,7 +47,6 @@
.WithEnvironment("REPOSITORIES", repositories)
.WithEnvironment("GUILD_ID", guildId)
.WithEnvironment("ROLE_ID", roleId)
.WithEnvironment("PORT", "3000")
.PublishAsDockerFile()
.PublishAsAzureContainerApp((infra, app) =>
{
Expand Down
12 changes: 4 additions & 8 deletions ContribBot.AppHost/ContribBot.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.4.0" />
<Project Sdk="Aspire.AppHost.Sdk/13.3.0-preview.1.26118.7">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>ef99776f-7ec9-4f51-b3e2-ac7d85305153</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.4.0" />
<PackageReference Include="Aspire.Hosting.Azure.AppContainers" Version="9.4.0" />
<PackageReference Include="Aspire.Hosting.NodeJs" Version="9.4.0" />
<PackageReference Include="CommunityToolkit.Aspire.Hosting.NodeJS.Extensions" Version="9.6.0" />
<PackageReference Include="Aspire.Hosting.Azure.AppContainers" Version="13.3.0-preview.1.26118.7" />
<PackageReference Include="Aspire.Hosting.JavaScript" Version="13.3.0-preview.1.26118.7" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
<add key="https://api.nuget.org/v3/index.json" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json">
<package pattern="Aspire*" />
</packageSource>
<packageSource key="https://api.nuget.org/v3/index.json">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
43 changes: 9 additions & 34 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,16 @@ async function checkContributionsToRepos(githubUsername: string, repositories: s
const [owner, repoName] = repo.split('/');
if (!owner || !repoName) continue;

let allCommits: any[] = [];
let page = 1;
let hasMore = true;

while (hasMore) {
try {
const { data: commits } = await octokit.repos.listCommits({
owner,
repo: repoName,
since: sixMonthsAgo.toISOString(),
per_page: 100,
page
});

if (commits.length === 0) {
hasMore = false;
} else {
allCommits.push(...commits);
page++;
if (commits.length < 100 || page > 20) {
hasMore = false;
}
}
} catch (error) {
hasMore = false;
}
}

// Check if user has contributed to this repository
const hasContributedToThis = allCommits.some(commit =>
commit.author?.login?.toLowerCase() === githubUsername.toLowerCase() ||
commit.committer?.login?.toLowerCase() === githubUsername.toLowerCase()
);
// Use server-side author filter — no need to paginate through all commits
const { data: commits } = await octokit.repos.listCommits({
owner,
repo: repoName,
author: githubUsername,
since: sixMonthsAgo.toISOString(),
per_page: 1
});

if (hasContributedToThis) {
if (commits.length > 0) {
return { hasContributed: true, contributedRepo: repo };
}

Expand Down