diff --git a/.github/workflows/cr.yml b/.github/workflows/cr.yml index 1f15911..f0d9b18 100644 --- a/.github/workflows/cr.yml +++ b/.github/workflows/cr.yml @@ -6,7 +6,10 @@ name: Code Review on: pull_request_target: - types: [opened, synchronize, reopened] + types: + - opened # Triggers when a PR is opened + - reopened # Triggers when a PR is reopened + - synchronize # Triggers when a commit is pushed to the PR # fix: GraphQL: Resource not accessible by integration (addComment) error permissions: diff --git a/README.md b/README.md index f491e29..89b0b6f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ - Analyze Commit Changes with Deepseek for Any Local Repository with CLI - Fully Customizable: Choose Models, Base URLs, and Prompts - Supports Self-Hosted Deepseek Models for Enhanced Flexibility -- Add `skip cr` or `skip review` to PR title or body to disable code review +- Add `skip cr` or `skip review` to PR title or body to disable code review in GitHub Actions +- Cross-platform Support: Compatible with GitHub Runners across `macOS`, `Ubuntu`, and `Windows`. ## Planned Features @@ -18,11 +19,16 @@ ## Code Review with GitHub Action +Add a GitHub workflow with the following contents: + ```yaml name: Code Review on: pull_request_target: - types: [opened] + types: + - opened # Triggers when a PR is opened + - reopened # Triggers when a PR is reopened + - synchronize # Triggers when a commit is pushed to the PR # fix: GraphQL: Resource not accessible by integration (addComment) error permissions: @@ -39,6 +45,8 @@ jobs: chat-token: ${{ secrets.CHAT_TOKEN }} ``` +When a PR is created, Deepseek code review will be automatically triggered, and the review results will be posted as comments on the corresponding PR. For example: [Example](https://github.com/hustcer/deepseek-review/pull/30) & [Run Log](https://github.com/hustcer/deepseek-review/actions/runs/13043609677/job/36390331791#step:2:53). + ## Input Parameters | Name | Type | Description | @@ -46,7 +54,7 @@ jobs: | chat-token | String | Required, Deepseek API Token | | model | String | Optional, the model used for code review, defaults to `deepseek-chat` | | base-url | String | Optional, Deepseek API Base URL, defaults to `https://api.deepseek.com` | -| max-length | Int | Optional, Maximum length of the content for review, if the content length exceeds this value, the review will be skipped. Default `0` means no limit. | +| max-length | Int | Optional, Maximum length(Unicode width) of the content for review, if the content length exceeds this value, the review will be skipped. Default `0` means no limit. | | sys-prompt | String | Optional, system prompt corresponding to `$sys_prompt` in the payload, default value see note below | | user-prompt | String | Optional, user prompt corresponding to `$user_prompt` in the payload, default value see note below | | github-token | String | Optional, The `GITHUB_TOKEN` secret or personal access token to authenticate. Defaults to `github.token`. | @@ -75,7 +83,7 @@ jobs: ### Required Tools -To perform code reviews locally, you need to install the following tools: +To perform code reviews locally(should works for `macOS`, `Ubuntu`, and `Windows`), you need to install the following tools: - [`Nushell`](https://www.nushell.sh/book/installation.html) & [`Just`](https://just.systems/man/en/packages.html). It is recommended to install the latest versions. - If you need to review GitHub PRs locally, you also need to install [`gh`](https://cli.github.com/). diff --git a/README.zh-CN.md b/README.zh-CN.md index e4a6d14..2b73616 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -7,7 +7,8 @@ - 通过本地 CLI 使用 Deepseek 分析任何本地仓库的提交变更 - 完全可定制:选择模型、基础 URL 和提示词 - 支持自托管 Deepseek 模型,提供更强的灵活性 -- 在 PR 的标题或描述中添加 `skip cr` or `skip review` 可跳过代码审查 +- 在 PR 的标题或描述中添加 `skip cr` or `skip review` 可跳过 GitHub Actions 里的代码审查 +- 跨平台:支持 GitHub `macOS`, `Ubuntu` & `Windows` Runners ## 计划支持特性 @@ -16,11 +17,16 @@ ## 通过 GitHub Action 进行代码审核 +创建一个 GitHub workflow 内容如下: + ```yaml name: Code Review on: pull_request_target: - types: [opened] + types: + - opened # Triggers when a PR is opened + - reopened # Triggers when a PR is reopened + - synchronize # Triggers when a commit is pushed to the PR # fix: GraphQL: Resource not accessible by integration (addComment) error permissions: @@ -37,6 +43,8 @@ jobs: chat-token: ${{ secrets.CHAT_TOKEN }} ``` +当 PR 创建的时候会自动触发 Deepseek 代码审核,并将审核结果以评论的方式发布到对应的 PR 上。比如:[示例](https://github.com/hustcer/deepseek-review/pull/30) & [运行日志](https://github.com/hustcer/deepseek-review/actions/runs/13043609677/job/36390331791#step:2:53) + ## 输入参数 | 名称 | 类型 | 描述 | @@ -44,7 +52,7 @@ jobs: | chat-token | String | 必填,Deepseek API Token | | model | String | 可选,配置代码审核选用的模型,默认为 `deepseek-chat` | | base-url | String | 可选,Deepseek API Base URL, 默认为 `https://api.deepseek.com` | -| max-length | Int | 可选,待审核内容的最大长度, 默认 `0` 表示没有限制,超过非零值则跳过审核 | +| max-length | Int | 可选,待审核内容的最大 Unicode 长度, 默认 `0` 表示没有限制,超过非零值则跳过审核 | | sys-prompt | String | 可选,系统 Prompt 对应入参中的 `$sys_prompt`, 默认值见后文注释 | | user-prompt | String | 可选,用户 Prompt 对应入参中的 `$user_prompt`, 默认值见后文注释 | | github-token | String | 可选,用于访问 API 进行 PR 管理的 GitHub Token,默认为 `${{ github.token }}` | @@ -73,7 +81,7 @@ Deepseek 接口调用入参: ### 依赖工具 -在本地进行代码审核需要安装以下工具: +在本地进行代码审核,支持 `macOS`, `Ubuntu` & `Windows` 不过需要安装以下工具: - [`Nushell`](https://www.nushell.sh/book/installation.html) & [`Just`](https://just.systems/man/en/packages.html), 建议安装最新版本 - 如果你需要在本地审核 GitHub PRs 还需要安装 [`gh`](https://cli.github.com/)