-
Notifications
You must be signed in to change notification settings - Fork 2
github action #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: GPT Pull Request Updater | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
update_pull_request: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Checkout GPT-PullRequest-Updater | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ravilushqa/gpt-pullrequest-updater | ||
path: gpt-pullrequest-updater | ||
|
||
- name: Build description and review commands | ||
run: | | ||
cd gpt-pullrequest-updater | ||
go build -o description ./cmd/description | ||
go build -o review ./cmd/review | ||
|
||
- name: Update Pull Request Description | ||
run: | | ||
./gpt-pullrequest-updater/description | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
|
||
- name: Review Pull Request | ||
if: github.event.action == 'opened' | ||
run: | | ||
./gpt-pullrequest-updater/review | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
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 | |
|
||
## Usage | ||
|
||
Before running the commands, make sure you have set the following environment variables: | ||
### Review Command | ||
|
||
- `GITHUB_TOKEN`: Your GitHub token | ||
- `OPENAI_TOKEN`: Your OpenAI API token | ||
- `OWNER`: The owner of the GitHub repository | ||
- `REPO`: The name of the GitHub repository | ||
- `PR_NUMBER`: The pull request number you want to update or review | ||
Usage: | ||
``` | ||
review [OPTIONS] | ||
``` | ||
|
||
### Description Command | ||
Application Options: | ||
``` | ||
--gh-token= GitHub token [$GITHUB_TOKEN] | ||
--openai-token= OpenAI token [$OPENAI_TOKEN] | ||
--owner= GitHub owner [$OWNER] | ||
--repo= GitHub repo [$REPO] | ||
--pr-number= Pull request number [$PR_NUMBER] | ||
--test Test mode [$TEST] | ||
``` | ||
|
||
Help Options: | ||
``` | ||
-h, --help Show this help message | ||
``` | ||
|
||
The `description` command updates the pull request description with a high-level summary of the changes made. To run the command, execute: | ||
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. | ||
|
||
To run the `review` command, execute: | ||
|
||
``` | ||
./description | ||
./review --gh-token=<GITHUB_TOKEN> --openai-token=<OPENAI_TOKEN> --owner=<OWNER> --repo=<REPO> --pr-number=<PR_NUMBER> --test | ||
``` | ||
|
||
### Review Command | ||
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. | ||
|
||
The `review` command creates individual comments for each file and an overall review summary comment. To run the command, execute: | ||
### Description Command | ||
|
||
The usage for the `description` command is similar to the `review` command. Replace `review` with `description` in the command above and execute. | ||
|
||
|
||
## GitHub Action | ||
|
||
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`. | ||
|
||
Here's an example of what the workflow file could look like: | ||
|
||
```yaml | ||
name: GPT Pull Request Updater | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
update_pull_request: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Checkout GPT-PullRequest-Updater | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ravilushqa/gpt-pullrequest-updater | ||
path: gpt-pullrequest-updater | ||
|
||
- name: Build description and review commands | ||
run: | | ||
cd gpt-pullrequest-updater | ||
go build -o description ./cmd/description | ||
go build -o review ./cmd/review | ||
|
||
- name: Update Pull Request Description | ||
run: | | ||
./gpt-pullrequest-updater/description | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
|
||
- name: Review Pull Request | ||
if: github.event.action == 'opened' | ||
run: | | ||
./gpt-pullrequest-updater/review | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
|
||
``` | ||
./review | ||
``` | ||
|
||
### Test Mode | ||
Make sure to add your OpenAI API token to your repository secrets as `OPENAI_TOKEN`. | ||
|
||
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`: | ||
### Granting Permissions for GitHub Actions | ||
|
||
``` | ||
export TEST=true | ||
``` | ||
In order to use this GitHub Action, you need to grant the necessary permissions to the GitHub token. To do this, follow these steps: | ||
|
||
Then, run the desired command as described above. The generated content will be printed to the console. | ||
1. Go to the repository settings page: https://github.com/OWNER/REPO/settings | ||
2. Navigate to the "Actions" tab on the left side of the settings page. | ||
3. Scroll down to the "Workflow Permissions" section. | ||
|
||
## License | ||
Select "Read and Write" permissions for the actions. This will provide your token with the necessary rights to modify your repository. | ||
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. | ||
|
||
License | ||
This project is licensed under the MIT License. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code patch adds a tool for updating and reviewing GitHub pull requests. The commands The Improvement suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the code patch looks good. Here are some suggestions: