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
+95-20Lines changed: 95 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -30,40 +30,115 @@ This repository contains a tool for updating and reviewing GitHub pull requests
30
30
31
31
## Usage
32
32
33
-
Before running the commands, make sure you have set the following environment variables:
33
+
### Review Command
34
34
35
-
-`GITHUB_TOKEN`: Your GitHub token
36
-
-`OPENAI_TOKEN`: Your OpenAI API token
37
-
-`OWNER`: The owner of the GitHub repository
38
-
-`REPO`: The name of the GitHub repository
39
-
-`PR_NUMBER`: The pull request number you want to update or review
35
+
Usage:
36
+
```
37
+
review [OPTIONS]
38
+
```
40
39
41
-
### Description Command
40
+
Application Options:
41
+
```
42
+
--gh-token= GitHub token [$GITHUB_TOKEN]
43
+
--openai-token= OpenAI token [$OPENAI_TOKEN]
44
+
--owner= GitHub owner [$OWNER]
45
+
--repo= GitHub repo [$REPO]
46
+
--pr-number= Pull request number [$PR_NUMBER]
47
+
--test Test mode [$TEST]
48
+
```
49
+
50
+
Help Options:
51
+
```
52
+
-h, --help Show this help message
53
+
```
42
54
43
-
The `description` command updates the pull request description with a high-level summary of the changes made. To run the command, execute:
55
+
Before running the command, make sure you have set the appropriate options or environment variables. The command line options will take precedence over the environment variables.
Replace `<GITHUB_TOKEN>`, `<OPENAI_TOKEN>`, `<OWNER>`, `<REPO>`, and `<PR_NUMBER>` with the appropriate values. If you want to enable test mode, add the `--test` flag.
50
64
51
-
The `review` command creates individual comments for each file and an overall review summary comment. To run the command, execute:
65
+
### Description Command
66
+
67
+
The usage for the `description` command is similar to the `review` command. Replace `review` with `description` in the command above and execute.
68
+
69
+
70
+
## GitHub Action
71
+
72
+
This script can be used as a GitHub Action, allowing it to run automatically in your repository. To get started, add a new workflow file in your repository, such as: `.github/workflows/gpt_pullrequest_updater.yml`.
73
+
74
+
Here's an example of what the workflow file could look like:
75
+
76
+
```yaml
77
+
name: GPT Pull Request Updater
78
+
79
+
on:
80
+
pull_request:
81
+
types:
82
+
- opened
83
+
- synchronize
84
+
85
+
jobs:
86
+
update_pull_request:
87
+
runs-on: ubuntu-latest
88
+
89
+
steps:
90
+
- name: Set up Go
91
+
uses: actions/setup-go@v2
92
+
with:
93
+
go-version: 1.19
94
+
95
+
- name: Checkout GPT-PullRequest-Updater
96
+
uses: actions/checkout@v2
97
+
with:
98
+
repository: ravilushqa/gpt-pullrequest-updater
99
+
path: gpt-pullrequest-updater
100
+
101
+
- name: Build description and review commands
102
+
run: |
103
+
cd gpt-pullrequest-updater
104
+
go build -o description ./cmd/description
105
+
go build -o review ./cmd/review
106
+
107
+
- name: Update Pull Request Description
108
+
run: |
109
+
./gpt-pullrequest-updater/description
110
+
env:
111
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112
+
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
113
+
OWNER: ${{ github.repository_owner }}
114
+
REPO: ${{ github.event.repository.name }}
115
+
PR_NUMBER: ${{ github.event.number }}
116
+
117
+
- name: Review Pull Request
118
+
if: github.event.action == 'opened'
119
+
run: |
120
+
./gpt-pullrequest-updater/review
121
+
env:
122
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123
+
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
124
+
OWNER: ${{ github.repository_owner }}
125
+
REPO: ${{ github.event.repository.name }}
126
+
PR_NUMBER: ${{ github.event.number }}
52
127
53
-
```
54
-
./review
55
128
```
56
129
57
-
### Test Mode
130
+
Make sure to add your OpenAI API token to your repository secrets as `OPENAI_TOKEN`.
58
131
59
-
Both commands support a test mode that prints the generated content to the console instead of updating the pull request. To enable test mode, set the `TEST` environment variable to `true`:
132
+
### Granting Permissions for GitHub Actions
60
133
61
-
```
62
-
export TEST=true
63
-
```
134
+
In order to use this GitHub Action, you need to grant the necessary permissions to the GitHub token. To do this, follow these steps:
64
135
65
-
Then, run the desired command as described above. The generated content will be printed to the console.
136
+
1. Go to the repository settings page: https://github.com/OWNER/REPO/settings
137
+
2. Navigate to the "Actions" tab on the left side of the settings page.
138
+
3. Scroll down to the "Workflow Permissions" section.
66
139
67
-
## License
140
+
Select "Read and Write" permissions for the actions. This will provide your token with the necessary rights to modify your repository.
141
+
By following these steps, you'll grant the required permissions for the GPT-PullRequest-Updater GitHub Action to function properly, allowing it to update and review pull requests in your repository.
0 commit comments