diff --git a/ContribBot.AppHost/AppHost.cs b/ContribBot.AppHost/AppHost.cs index f878384..d1eb4fe 100644 --- a/ContribBot.AppHost/AppHost.cs +++ b/ContribBot.AppHost/AppHost.cs @@ -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) @@ -48,7 +47,6 @@ .WithEnvironment("REPOSITORIES", repositories) .WithEnvironment("GUILD_ID", guildId) .WithEnvironment("ROLE_ID", roleId) - .WithEnvironment("PORT", "3000") .PublishAsDockerFile() .PublishAsAzureContainerApp((infra, app) => { diff --git a/ContribBot.AppHost/ContribBot.AppHost.csproj b/ContribBot.AppHost/ContribBot.AppHost.csproj index c62d221..66f751e 100644 --- a/ContribBot.AppHost/ContribBot.AppHost.csproj +++ b/ContribBot.AppHost/ContribBot.AppHost.csproj @@ -1,20 +1,16 @@ - - - + Exe - net9.0 + net10.0 enable enable ef99776f-7ec9-4f51-b3e2-ac7d85305153 - - - - + + diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..b48b0b0 --- /dev/null +++ b/nuget.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index de0ec51..51a217d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 }; }