Language Check #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Language Check | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- '**.md' # 只在 markdown 文件变更时触发 | |
jobs: | |
lang-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # 获取完整的 git 历史,以便进行 diff 比较 | |
- name: Setup Git | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "[email protected]" | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq curl | |
- name: Run language check script | |
env: | |
DIFY_API_KEY: ${{ secrets.DIFY_API_KEY }} | |
run: | | |
chmod +x ./lang-check/git-diff.sh | |
output=$(./lang-check/git-diff.sh) | |
echo "$output" # 显示检查结果 | |
# 检查输出中是否包含 ❌ 符号 | |
if echo "$output" | grep -q "❌"; then | |
echo "检查发现问题,PR 不予通过" | |
exit 1 # 非零退出码会导致 Action 失败 | |
else | |
echo "检查通过" | |
exit 0 # 零退出码表示 Action 成功 | |
fi |