Skip to content

Commit 49e1020

Browse files
committed
more readme info
1 parent 167bb4e commit 49e1020

File tree

1 file changed

+78
-20
lines changed

1 file changed

+78
-20
lines changed

README.md

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,98 @@ This repository contains a tool for updating and reviewing GitHub pull requests
3030

3131
## Usage
3232

33-
Before running the commands, make sure you have set the following environment variables:
33+
### Review Command
3434

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+
```
4039

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+
```
4254

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.
56+
57+
To run the `review` command, execute:
4458

4559
```
46-
./description
60+
./review --gh-token=<GITHUB_TOKEN> --openai-token=<OPENAI_TOKEN> --owner=<OWNER> --repo=<REPO> --pr-number=<PR_NUMBER> --test
4761
```
4862

49-
### Review Command
63+
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.
5064

51-
The `review` command creates individual comments for each file and an overall review summary comment. To run the command, execute:
65+
### Description Command
5266

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.
5668

57-
### Test Mode
5869

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
6071

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
61111
```
62-
export TEST=true
63-
```
64112
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.
66122

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.
68125

126+
License
69127
This project is licensed under the MIT License.

0 commit comments

Comments
 (0)