{"id":16560748,"url":"https://github.com/adshao/chatgpt-code-review-action","last_synced_at":"2025-03-21T11:31:37.309Z","repository":{"id":97121988,"uuid":"608530586","full_name":"adshao/chatgpt-code-review-action","owner":"adshao","description":"A GitHub Action that uses OpenAI ChatGPT to do code review","archived":false,"fork":false,"pushed_at":"2023-03-09T03:10:16.000Z","size":484,"stargazers_count":72,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-13T15:39:27.064Z","etag":null,"topics":["ai","chatgpt","code-review","github","github-actions","openai"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adshao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-02T07:56:11.000Z","updated_at":"2025-03-11T03:32:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"80d53df5-03b4-4b90-abbb-879f072cf963","html_url":"https://github.com/adshao/chatgpt-code-review-action","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adshao%2Fchatgpt-code-review-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adshao%2Fchatgpt-code-review-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adshao%2Fchatgpt-code-review-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adshao%2Fchatgpt-code-review-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adshao","download_url":"https://codeload.github.com/adshao/chatgpt-code-review-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135898,"owners_count":20403797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chatgpt","code-review","github","github-actions","openai"],"created_at":"2024-10-11T20:29:54.411Z","updated_at":"2025-03-21T11:31:36.919Z","avatar_url":"https://github.com/adshao.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"### Simplify code reviews, just say `chatgpt`!\n\n# OpenAI ChatGPT Code Review\n\nA GitHub Action that uses OpenAI ChatGPT to analyze code in pull request comments.\n\n## Usage\n\nTo use this action in your workflow, add the following step:\n\n```yaml\nname: OpenAI ChatGPT Code Review\nuses: adshao/chatgpt-code-review-action@v0.2\nwith:\n    PROGRAMMING_LANGUAGE: 'JavaScript'\n    REVIEW_COMMENT_PREFIX: 'chatgpt:'\n    FULL_REVIEW_COMMENT: 'chatgpt'\n    OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}\n    GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}\n```\n\n## Inputs\n\nThis action accepts the following inputs:\n\n- `PROGRAMMING_LANGUAGE` (optional): The programming language of the code in the GitHub repository. If not provided, the detected programming language will be used.\n- `OPENAI_TOKEN` (required): The API token for the OpenAI ChatGPT API.\n- `GITHUB_TOKEN` (required): The API token for the Github API.\n- `FULL_REVIEW_COMMENT` (required): The comment to trigger code review for the pull request.\n- `REVIEW_COMMENT_PREFIX` (required): The comment prefix to trigger code review with the comment.\n- `GITHUB_BASE_URL` (optional): The base URL for the GitHub API.\n- `MAX_CODE_LENGTH` (optional): The maximum code length for the pull request code to be sent to OpenAI. The default value is 6000.\n- `PROMPT_TEMPLATE` (optional): The template for the FULL_REVIEW_COMMENT prompt. The default value is:\n```\nPlease analyze the pull request's code and inform me whether it requires optimization, and provide an explanation for your decision:\n\n${code}\n```\n- `ANSWER_TEMPLATE` (optional): The template for the answer sent to the GitHub comment. The default value is:\n```\nAI Code Review:\n\n${answer}\n```\n\n## Outputs\n\nThis action does not produce any outputs.\n\n## Example workflow\n\nHere's an example workflow that uses this action to analyze code in pull request comments:\n\n```yaml\nname: Code Review\n\non:\n  issue_comment:\n    types: [created, edited]\n\njobs:\n  code-review:\n    runs-on: ubuntu-latest\n    if: github.event.comment.user.login == 'adshao' \u0026\u0026 startsWith(github.event.comment.body, 'chatgpt')\n    steps:\n    - name: OpenAI ChatGPT Code Review\n      uses: adshao/chatgpt-code-review-action@v0.2\n      with:\n        PROGRAMMING_LANGUAGE: 'JavaScript'\n        OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}\n        GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}\n        FULL_REVIEW_COMMENT: 'chatgpt'\n        REVIEW_COMMENT_PREFIX: 'chatgpt:'\n```\n\nThis workflow runs the `OpenAI ChatGPT Code Review` action when a pull request comment is created or edited. The action uses the `PROGRAMMING_LANGUAGE`, `FULL_REVIEW_COMMENT`, `REVIEW_COMMENT_PREFIX`, `OPENAI_TOKEN` and `GITHUB_TOKEN` input values to analyze the code in the pull request comment.\n\nYou can also trigger github action when a pull request opened.\n\n## Github\n\n### Code Review for PR\n\nIf a comment exactly matches `chatgpt`, a code review will be triggered for the pull request's diff.\n\nNote that only the first 6000 characters of code will be used due to the token limit of the OpenAI API.\n\n### Code Review for a specific file\n\nIf a comment starts with `chatgpt:`, you can use it to communicate with ChatGPT just like you would in the official interface.\n\nTo reference the diff code of the pull request in your comment, use ${code}:\n\n```\nchatgpt: Please explain the usage of the `getPrCode` function:\n\n${code}\n```\n\nTo reference the diff code of a specific file in the pull request, use ${file:filename}:\n\n```\nchatgpt: Can you check if there are any bugs in the following code?\n\n${file:dist/index.js}\n```\n\n## Screenshots\n\n![demo](https://pbs.twimg.com/media/FqOsplnaMAERrgP?format=jpg\u0026name=large)\n\n![code_review_for_file](https://pbs.twimg.com/media/FqvwanLaIAAd2l6?format=jpg\u0026name=large)\n\n## More Examples\n\n`go-binance`: https://github.com/adshao/go-binance/pull/461#issuecomment-1452922686\n\n## License\n\nThe code in this repository is licensed under the MIT license. See `LICENSE` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadshao%2Fchatgpt-code-review-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadshao%2Fchatgpt-code-review-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadshao%2Fchatgpt-code-review-action/lists"}