1
0
mirror of https://github.com/hustcer/deepseek-review.git synced 2026-05-13 05:16:05 +08:00

breaking: Change DEEPSEEK_TOKEN to CHAT_TOKEN (#50)

* breaking: Change DEEPSEEK_TOKEN to CHAT_TOKEN

* breaking: Change DEEPSEEK_TOKEN to CHAT_TOKEN
This commit is contained in:
Justin Ma
2025-01-31 08:18:19 +08:00
committed by GitHub
parent a7fd374fc1
commit e94ff03208
7 changed files with 18 additions and 19 deletions

View File

@@ -2,8 +2,8 @@
# Usage: Copy this file to .env and replace the values with your own
# WARNING: Do not commit the actual .env file to version control as it may contain sensitive information.
# DEEPSEEK_TOKEN: Obtain this token from your Deepseek account settings
DEEPSEEK_TOKEN='Your Deepseek API token'
# CHAT_TOKEN: Obtain this token from your Deepseek account settings
CHAT_TOKEN='Your Deepseek API token'
# GITHUB_TOKEN: Your GitHub API token to query GitHub PR changes
# Generate this token from your GitHub account with the necessary permissions
GITHUB_TOKEN='Your GitHub API token'

View File

@@ -20,4 +20,4 @@ jobs:
- name: Deepseek Code Review
uses: hustcer/deepseek-review@develop
with:
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
chat-token: ${{ secrets.CHAT_TOKEN }}

View File

@@ -36,14 +36,14 @@ jobs:
- name: Deepseek Code Review
uses: hustcer/deepseek-review@v1
with:
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
chat-token: ${{ secrets.CHAT_TOKEN }}
```
## Input Parameters
| Name | Type | Description |
| -------------- | ------ | ----------------------------------------------------------------------- |
| deepseek-token | String | Required, Deepseek API Token |
| 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` |
| sys-prompt | String | Optional, system prompt corresponding to `$sys_prompt` in the payload, default value see note below |
@@ -99,7 +99,7 @@ Flags:
-h, --help: Display the help message for this command
Parameters:
token <string>: Your Deepseek API token, fallback to DEEPSEEK_TOKEN (optional)
token <string>: Your Deepseek API token, fallback to CHAT_TOKEN (optional)
```

View File

@@ -34,14 +34,14 @@ jobs:
- name: Deepseek Code Review
uses: hustcer/deepseek-review@v1
with:
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
chat-token: ${{ secrets.CHAT_TOKEN }}
```
## 输入参数
| 名称 | 类型 | 描述 |
| -------------- | ------ | -------------------------------------------------------------- |
| deepseek-token | String | 必填Deepseek API Token |
| chat-token | String | 必填Deepseek API Token |
| model | String | 可选,配置代码审核选用的模型,默认为 `deepseek-chat` |
| base-url | String | 可选Deepseek API Base URL, 默认为 `https://api.deepseek.com` |
| sys-prompt | String | 可选,系统 Prompt 对应入参中的 `$sys_prompt`, 默认值见后文注释 |
@@ -97,7 +97,7 @@ Flags:
-h, --help: Display the help message for this command
Parameters:
token <string>: Your Deepseek API token, fallback to DEEPSEEK_TOKEN (optional)
token <string>: Your Deepseek API token, fallback to CHAT_TOKEN (optional)
```

View File

@@ -15,7 +15,7 @@ branding:
color: 'purple'
inputs:
deepseek-token:
chat-token:
required: true
description: 'Your deepseek API token.'
model:
@@ -52,7 +52,7 @@ runs:
let ghToken = '${{ github.token }}'
let baseUrl = '${{inputs.base-url}}'
let repo = '${{ github.repository }}'
let token = '${{inputs.deepseek-token}}'
let token = '${{inputs.chat-token}}'
let sysPrompt = '${{inputs.sys-prompt}}'
let userPrompt = '${{inputs.user-prompt}}'
let pr = '${{ github.event.pull_request.number }}'

View File

@@ -39,6 +39,7 @@ commit_parsers = [
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^breaking", group = "Breaking Changes"},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
{ message = "^chore\\(release\\): prepare for", skip = true},

View File

@@ -10,7 +10,7 @@
# Description: A script to do code review by deepseek
# Env vars:
# GITHUB_TOKEN: Your GitHub API token
# DEEPSEEK_TOKEN: Your Deepseek API token
# CHAT_TOKEN: Your Deepseek API token
# BASE_URL: Deepseek API base URL
# SYSTEM_PROMPT: System prompt message
# USER_PROMPT: User prompt message
@@ -40,7 +40,7 @@ const DEFAULT_OPTIONS = {
# Use Deepseek AI to review code changes locally or in GitHub Actions
export def --env deepseek-review [
token?: string, # Your Deepseek API token, fallback to DEEPSEEK_TOKEN env var
token?: string, # Your Deepseek API token, fallback to CHAT_TOKEN env var
--debug(-d), # Debug mode
--repo(-r): string, # GitHub repository name, e.g. hustcer/deepseek-review
--pr-number(-n): string, # GitHub PR number
@@ -54,7 +54,7 @@ export def --env deepseek-review [
]: nothing -> nothing {
$env.config.table.mode = 'psql'
let is_action = ($env.GITHUB_ACTIONS? == 'true')
let token = $token | default $env.DEEPSEEK_TOKEN?
let token = $token | default $env.CHAT_TOKEN?
let repo = $repo | default $env.DEFAULT_GITHUB_REPO?
let header = [Authorization $'Bearer ($token)']
let url = $'($base_url)/chat/completions'
@@ -68,12 +68,12 @@ export def --env deepseek-review [
}
$env.GH_TOKEN = $gh_token | default $env.GITHUB_TOKEN?
if ($token | is-empty) {
print $'(ansi r)Please provide your Deepseek API token by setting `DEEPSEEK_TOKEN` or passing it as an argument.(ansi reset)'
return
print $'(ansi r)Please provide your Deepseek API token by setting `CHAT_TOKEN` or passing it as an argument.(ansi reset)'
exit $ECODE.INVALID_PARAMETER
}
if $is_action and not (is-installed gh) {
print $'(ansi r)Please install GitHub CLI from https://cli.github.com (ansi reset)'
return
exit $ECODE.MISSING_BINARY
}
let hint = if not $is_action and ($pr_number | is-empty) {
$'🚀 Initiate the code review by Deepseek AI for local changes ...'
@@ -98,13 +98,11 @@ export def --env deepseek-review [
if ($response | is-empty) {
print $'(ansi r)Oops, No response returned from Deepseek API.(ansi reset)'
exit $ECODE.SERVER_ERROR
return
}
if $debug { print $'Deepseek Response:'; hr-line; $response | table -e | print }
if ($response | describe) == 'string' {
print $'❌ Code review failedError: '; hr-line; print $response
exit $ECODE.SERVER_ERROR
return
}
let review = $response | get -i choices.0.message.content
if not $is_action {