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
+78-20Lines changed: 78 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -30,40 +30,98 @@ 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
52
66
53
-
```
54
-
./review
55
-
```
67
+
The usage for the `description` command is similar to the `review` command. Replace `review` with `description` in the command above and execute.
56
68
57
-
### Test Mode
58
69
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`:
70
+
## GitHub Action
60
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_pr:
87
+
runs-on: ubuntu-latest
88
+
steps:
89
+
- name: Check out the repository
90
+
uses: actions/checkout@v2
91
+
92
+
- name: Set up Go
93
+
uses: actions/setup-go@v2
94
+
with:
95
+
go-version: 1.19
96
+
97
+
- name: Build the commands
98
+
run: |
99
+
go build -o description ./cmd/description
100
+
go build -o review ./cmd/review
101
+
102
+
- name: Run the GPT Updater
103
+
run: |
104
+
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
105
+
export OPENAI_TOKEN=${{ secrets.OPENAI_TOKEN }}
106
+
export OWNER=${{ github.repository_owner }}
107
+
export REPO=${{ github.event.repository.name }}
108
+
export PR_NUMBER=${{ github.event.number }}
109
+
./description
110
+
./review
61
111
```
62
-
export TEST=true
63
-
```
64
112
65
-
Then, run the desired command as described above. The generated content will be printed to the console.
113
+
Make sure to add your OpenAI API token to your repository secrets as `OPENAI_TOKEN`.
114
+
115
+
### Granting Permissions for GitHub Actions
116
+
117
+
In order to use this GitHub Action, you need to grant the necessary permissions to the GitHub token. To do this, follow these steps:
118
+
119
+
1. Go to the repository settings page: https://github.com/OWNER/REPO/settings
120
+
2. Navigate to the "Actions" tab on the left side of the settings page.
121
+
3. Scroll down to the "Workflow Permissions" section.
66
122
67
-
## License
123
+
Select "Read and Write" permissions for the actions. This will provide your token with the necessary rights to modify your repository.
124
+
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