You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-10Lines changed: 42 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,23 @@ A Node.js server for GitHub app to assist external contributors and save maintai
7
7
-[x] When an external contributor (not the internal team) raises a PR, post a comment to sign CLA and label PR `Pending CLA`
8
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
9
9
-[x] On `rudder-transformer` PR merge, post a comment to raise PR in `integrations-config`
10
-
-[ ] On `integrations-config` PR merge, psot a comment to join Slack's product-releases channel to get notified when that integration goes live
10
+
-[ ] On `integrations-config` PR merge, post a comment to join Slack's product-releases channel to get notified when that integration goes live
11
11
-[ ] On `integrations-config` PR merge, post a comment to raise PR in `rudder-docs`
12
12
-[x] List of open PRs by external contributors
13
+
-[x] Notify on Slack when `product review` label is added to a PR
14
+
-[ ] Analyze merged PRs and suggest next actions
15
+
-[x] Analyze docs pages using AI on PR labelled with `docs review`
16
+
17
+
## Features
18
+
19
+
### Next Actions Feature
20
+
21
+
The Next Actions feature automatically analyzes merged pull requests from external contributors and suggests next actions based on the code changes. Here's how it works:
22
+
23
+
1.**Triggers**: Listens to `pull_request.closed` events and checks if the PR was merged
24
+
2.**Analysis**: Extracts production code changes (excludes test files)
25
+
3.**External API**: Sends changes to services such as DocsAgent
26
+
4.**Comments**: Posts the API response as a comment on the PR
13
27
14
28
## Requirements
15
29
@@ -26,7 +40,7 @@ A Node.js server for GitHub app to assist external contributors and save maintai
26
40
2. Create a `.env` file similar to `.env.example` and set actual values. If you are using GitHub Enterprise Server, also include a `ENTERPRISE_HOSTNAME` variable and set the value to the name of your GitHub Enterprise Server instance.
27
41
3. Install dependencies with `npm install`.
28
42
4. Start the server with `npm run server`.
29
-
5. Ensure your server is reachable from the internet.
43
+
5. Ensure your server is reachable from the internet. This is necessary for GitHub to send webhook events to your local server.
30
44
- If you're using `smee`, run `smee -u <smee_url> -t http://localhost:3000/api/webhook`.
31
45
6. Ensure your GitHub App includes at least one repository on its installations.
32
46
@@ -35,15 +49,33 @@ A Node.js server for GitHub app to assist external contributors and save maintai
35
49
### Using `Docker`
36
50
37
51
1.[Register a GitHub app](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) for your GitHub organization. Make sure to activate the webhook with webhook url `https://YOUR_WEBSITE/api/webhook` in your app with a secret. Enable Permissions & Events as you may need, at minimum pull_request and issue related events should be enabled.
38
-
2. Installyour GitHub app in all the repos where you need this app.
52
+
2. Installyour GitHub app in all the repos where you need this app.
39
53
3. Clone this repo OR download the [`build/docker-compose.yml`](./build/docker-compose.yml) to install via dockerhub image
40
-
4. Update `docker-compose.yml` environment variables with the details received from the step 2
41
-
> To convert GitHub App's private key to base64, use this command - `openssl base64 -in /path/to/original-private-key.pem -out ./base64EncodedKey.txt -A`
42
-
5. Run `docker-componse build` to build the service
43
-
6. Run `docker-compose up` to create and start the container
44
-
7. Test by visiting `http://localhost:3000` OR whatever `WEBSITE_ADDRESS` environment variable you've configured
54
+
4. Update the `docker-compose.yml` file with the environment variables obtained from step 2. Make sure to replace placeholder values with your actual GitHub App details.
55
+
5. To convert GitHub App's private key to base64, use this command:
56
+
```
57
+
openssl base64 -in /path/to/original-private-key.pem -out ./base64EncodedKey.txt -A
58
+
```
59
+
6. Run `docker-compose build` to build the service
60
+
7. Run `docker-compose up` to create and start the container
61
+
8. Test by visiting `http://localhost:3000` OR whatever `WEBSITE_ADDRESS` environment variable you've configured
62
+
63
+
## Advanced Features Setup
64
+
65
+
### Docs Agent Setup
66
+
67
+
To set up the Docs Agent feature:
68
+
69
+
1. Locate your Docs Agent API project. This is a separate service that analyzes documentation and provides suggestions.
70
+
2. In the Docs Agent API project's environment configuration, add the following URL to the `ALLOWED_WEBHOOK_URLS` variable:
71
+
```
72
+
https://your-github-app-host.com/api/comment
73
+
```
74
+
Replace `your-github-app-host.com` with the actual hostname where your GitHub App is deployed.
75
+
76
+
This setup allows the Docs Agent to send webhook requests to your GitHub App.
45
77
46
-
## Usage
78
+
## How It Works
47
79
48
80
With your server running, you can now create a pull request on any repository that
49
81
your app can access. GitHub will emit a `pull_request.opened` event and will deliver
console.log(`Found ${docsFiles.length} docs files being changed`);
135
+
if(docsFiles.length===0){
136
+
thrownewError("No docs files being changed in this PR");
137
+
}
138
+
for(constfileofdocsFiles){
139
+
constcontent=file.content;
140
+
// Convert relative file path to full remote github file path using PR head commit SHA https://raw.githubusercontent.com/gitcommitshow/rudder-github-app/e14433e76d74dc680b8cf9102d39f31970e8b794/.codesandbox/tasks.json
constwebhookUrl=process.env.API_POST_GITHUB_COMMENT||(getWebsiteAddress()+"/api/comment");//TODO: add this url to `ALLOWED_WEBHOOK_URLS` env of docs-agent project
144
+
DocsAgent.reviewDocs(content,fullPath,{
145
+
webhookUrl: webhookUrl,
146
+
webhookMetadata: {
147
+
issue_number: pull_request.number,
148
+
repo: repository.name,
149
+
owner: repository.owner.login,
150
+
},
151
+
});
152
+
console.log(`Successfully started docs review for ${fullPath}, results will be handled by webhook: ${webhookUrl}`);
153
+
}
154
+
console.log(`Successfully started all necessary docs reviews for PR ${repository.name} #${pull_request.number}`);
0 commit comments