ci: 改进文档翻译工作流并添加失败处理

- 添加获取短SHA步骤用于PR标题
- 在翻译脚本中添加失败退出逻辑

Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
longjin 2025-05-22 17:14:36 +08:00
parent 8c7a753d13
commit b7b5ea2c51
2 changed files with 13 additions and 1 deletions

View File

@ -16,6 +16,13 @@ jobs:
with:
fetch-depth: 0
- id: get-short_sha
uses: actions/github-script@v7.0.1
with:
script: |
const short_sha = context.sha.substring(0, 8)
core.setOutput('short_sha', short_sha)
- name: Set up Python
uses: actions/setup-python@v5
with:
@ -45,7 +52,7 @@ jobs:
uses: peter-evans/create-pull-request@v5
with:
commit-message: "Update translated documentation"
title: "docs: Translation update [${{ format('{0:.7}', github.sha) }}]"
title: "docs: Translation update [${{steps.get-short_sha.outputs.short_sha}}]"
body: |
Automated translation update triggered by docs changes
Commit: ${{ github.sha }}

View File

@ -22,6 +22,7 @@ import re
import hashlib
import json
from pathlib import Path
import sys
import threading
from typing import List, Dict, Tuple
import openai
@ -454,6 +455,7 @@ class DocumentTranslator:
lang_pbar.close()
print(
f"\n翻译完成! Succ: {total_tasks-self.fail_count}, Fail: {self.fail_count}")
if __name__ == "__main__":
@ -465,3 +467,6 @@ if __name__ == "__main__":
translator = DocumentTranslator()
translator.run()
if translator.fail_count > 0:
sys.exit(1)