Skip to content

Commit 9c017bc

Browse files
Fix cla 504 (#51)
* fix: replace gh api from pulls to search to avoid rate limits * test: add some working integration and pending e2e tests * fix: error handling in case of missing referr * feat: improve ux in case of failure * fix: installation auth issues to support org wide label removal
1 parent bb07086 commit 9c017bc

File tree

12 files changed

+1632
-428
lines changed

12 files changed

+1632
-428
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ A Node.js server for GitHub app to assist external contributors and save maintai
55
## Roadmap
66

77
- [x] When an external contributor (not the internal team) raises a PR, post a comment to sign CLA and label PR `Pending CLA`
8-
- [x] On signing CLA, remove `Pending CLA` label and never ask that user to sign the CLA again on any of our repo in future
8+
- [x] On signing CLA, remove `Pending CLA` label from all the PRs of that user. Never ask that user to sign the CLA on any of our repo in future
99
- [x] On `rudder-transformer` PR merge, post a comment to raise PR in `integrations-config`
1010
- [ ] On `integrations-config` PR merge, psot a comment to join Slack's product-releases channel to get notified when that integration goes live
11+
- [ ] On `integrations-config` PR merge, post a comment to raise PR in `rudder-docs`
1112

1213
## Requirements
1314

@@ -60,4 +61,9 @@ by major cloud providers:
6061
[Azure Key Vault](https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-node?tabs=windows),
6162
[AWS Secrets Manager](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-secrets-manager/),
6263
[Google Secret Manager](https://cloud.google.com/nodejs/docs/reference/secret-manager/latest),
63-
etc.
64+
etc.
65+
66+
## References
67+
68+
- [Docs - octokit.rest.* methods](https://github.com/octokit/plugin-rest-endpoint-methods.js/tree/main/docs)
69+
- [Docs - GitHub API](https://docs.github.com/en/rest)

app.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Octokit, App } from "octokit";
66
import { createNodeMiddleware } from "@octokit/webhooks";
77
import { routes } from "./src/routes.js";
88
import {
9+
verifyGitHubAppAuthenticationAndAccess,
910
getMessage,
1011
isCLARequired,
1112
isMessageAfterMergeRequired,
@@ -57,6 +58,7 @@ const app = new App({
5758
}),
5859
}),
5960
});
61+
await verifyGitHubAppAuthenticationAndAccess(app);
6062

6163
// Optional: Get & log the authenticated app's name
6264
const { data } = await app.octokit.request("/app");
@@ -108,6 +110,7 @@ app.webhooks.on("pull_request.labeled", async ({ octokit, payload }) => {
108110
repo: repository.name,
109111
pr_number: pull_request.number,
110112
});
113+
// Docs for octokit.rest.issues.createComment - https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/main/docs/issues/createComment.md
111114
await octokit.rest.issues.createComment({
112115
owner: repository.owner.login,
113116
repo: repository.name,
@@ -143,6 +146,7 @@ app.webhooks.on("pull_request.closed", async ({ octokit, payload }) => {
143146
repo: payload.repository.name,
144147
pr_number: payload.pull_request.number,
145148
});
149+
// Docs for octokit.rest.issues.createComment - https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/main/docs/issues/createComment.md
146150
await octokit.rest.issues.createComment({
147151
owner: payload.repository.owner,
148152
repo: payload.repository.name,
@@ -163,6 +167,7 @@ app.webhooks.on("pull_request.closed", async ({ octokit, payload }) => {
163167
app.webhooks.on("issues.opened", async ({ octokit, payload }) => {
164168
console.log(`Received a new issue event for #${payload.issue.number}`);
165169
try {
170+
// Docs for octokit.rest.issues.createComment - https://github.com/octokit/plugin-rest-endpoint-methods.js/tree/main/docs/issues/createComment.md
166171
await octokit.rest.issues.createComment({
167172
owner: payload.repository.owner.login,
168173
repo: payload.repository.name,
@@ -199,11 +204,11 @@ app.webhooks.onError((error) => {
199204

200205
// Launch a web server to listen for GitHub webhooks
201206
const port = process.env.PORT || 3000;
202-
const path = "/api/webhook";
203-
const localWebhookUrl = `http://localhost:${port}${path}`;
207+
const webhookPath = "/api/webhook";
208+
const localWebhookUrl = `http://localhost:${port}${webhookPath}`;
204209

205210
// See https://github.com/octokit/webhooks.js/#createnodemiddleware for all options
206-
const middleware = createNodeMiddleware(app.webhooks, { path });
211+
const middleware = createNodeMiddleware(app.webhooks, { path: webhookPath });
207212

208213
http
209214
.createServer((req, res) => {

0 commit comments

Comments
 (0)