diff --git a/.github/workflows/lang-check.yml b/.github/workflows/lang-check.yml index 0f8c2bcd..67892e86 100644 --- a/.github/workflows/lang-check.yml +++ b/.github/workflows/lang-check.yml @@ -1,10 +1,10 @@ -name: Automatic Language Check +name: Language Check on: pull_request: types: [opened, synchronize] paths: - - '**.md' # Only trigger on markdown file changes + - '**.md' # 只在 markdown 文件变更时触发 jobs: lang-check: @@ -14,7 +14,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 0 # Get full git history for diff comparison + fetch-depth: 0 # 获取完整的 git 历史,以便进行 diff 比较 - name: Setup Git run: | @@ -32,17 +32,13 @@ jobs: run: | chmod +x ./lang-check/git-diff.sh output=$(./lang-check/git-diff.sh) - echo "$output" # Display check results + echo "$output" # 显示检查结果 - # Check if output contains ❌ symbol + # 检查输出中是否包含 ❌ 符号 if echo "$output" | grep -q "❌"; then - # Clean up temporary file before exit - rm -f ./lang-check/commit-*.txt - echo "Check failed, PR cannot be merged" - exit 1 # Non-zero exit code will fail the Action + echo "检查发现问题,PR 不予通过" + exit 1 # 非零退出码会导致 Action 失败 else - # Clean up temporary file before exit - rm -f ./lang-check/commit-*.txt - echo "Check passed" - exit 0 # Zero exit code indicates Action success + echo "检查通过" + exit 0 # 零退出码表示 Action 成功 fi \ No newline at end of file diff --git a/lang-check/commit-96732-0214.txt b/lang-check/commit-96732-0214.txt deleted file mode 100644 index df5c7cc3..00000000 --- a/lang-check/commit-96732-0214.txt +++ /dev/null @@ -1,14 +0,0 @@ - - -# 一个文档 - -不加xxx中英文空格 - -- xxxx - -https://langgenius.feishu.cn/ - -测试31231三大 - - - diff --git a/lang-check/git-diff.sh b/lang-check/git-diff.sh index 12587171..c1e96077 100755 --- a/lang-check/git-diff.sh +++ b/lang-check/git-diff.sh @@ -1,5 +1,16 @@ #!/bin/bash +# 加载 .env 文件 +if [ -f "$(dirname "$0")/.env" ]; then + source "$(dirname "$0")/.env" +fi + +# 检查环境变量是否存在 +if [ -z "${DIFY_API_KEY}" ]; then + echo "错误:未设置 DIFY_API_KEY 环境变量" + exit 1 +fi + # 初始化调试模式标志 debug_mode=false @@ -124,8 +135,20 @@ fi # 检查 curl 是否成功 if [ $? -ne 0 ]; then echo "错误:API 请求超时或失败" + # 清理临时文件 + rm -f "$log_file" exit 1 fi -# 只输出 API 响应 -echo "$response" \ No newline at end of file +# 输出 API 响应 +echo "$response" + +# 清理临时文件 +rm -f "$log_file" + +# 检查响应中是否包含错误标记 +if echo "$response" | grep -q "❌"; then + exit 1 +else + exit 0 +fi \ No newline at end of file diff --git a/lang-check/git-tcommit.sh b/lang-check/git-tcommit.sh new file mode 100755 index 00000000..1769bbf2 --- /dev/null +++ b/lang-check/git-tcommit.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# 运行语言检查脚本 +if bash ./lang-check/git-diff.sh; then + # 检查通过,执行提交 + git commit -m "$*" +else + # 检查失败 + echo "Language check failed, commit aborted" + exit 1 +fi \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..ad3485a7 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "dify-docs", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{}