docs(sync): 🤖 同步 [docs/[lang]/README.md] [[script]/README_[lang].md]
#142
Workflow file for this run
This file contains hidden or 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: Sync Readme Files | |
| on: | |
| push: | |
| paths: | |
| - "**/CHANGELOG.md" # 脚本更新日志 | |
| - "**/README.md" # 脚本介绍文件 | |
| - "docs/ScriptsPath.json" # 脚本列表 | |
| workflow_dispatch: | |
| jobs: | |
| run-python: | |
| if: ${{ github.event.commits[0].committer.username != 'ChinaGodBot' }} | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Asia/Shanghai | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.QWY_SYNC_BOT_TOKEN }} | |
| fetch-depth: 0 #检查时间用. | |
| - name: 设置 Node.js | |
| uses: actions/setup-node@v4.4.0 | |
| with: | |
| node-version: "20.18.0" | |
| - name: 设置 Python | |
| uses: actions/setup-python@v5.6.0 | |
| with: | |
| python-version: "3.12.4" | |
| - name: pip | |
| run: pip install -r utils/requirements.txt | |
| - name: npm | |
| run: npm install | |
| - name: 检查新脚本 | |
| run: python utils/script-import-sync.py | |
| env: | |
| GFU: ${{ secrets.GFU }} | |
| GFP: ${{ secrets.GFP }} | |
| GREASYFORK_TOTP_SECRET: ${{ secrets.GREASYFORK_TOTP_SECRET }} | |
| #- name: 相关脚本 | |
| # run: python utils/update_related_scripts.py | |
| #- name: 所有脚本 | |
| # run: python utils/update_related_all_scripts.py | |
| - name: 导航栏 | |
| run: python utils/navigation.py | |
| - name: 变更日志 | |
| run: python utils/merge_change_history.py | |
| - name: 刷新仓库自述中的脚本列表 | |
| run: python utils/update_scripts_list.py | |
| - name: 翻译仓库自述 | |
| run: python utils/translate_force_chinese_to_lang.py | |
| - name: 修复其他语言readme中的相对路径 | |
| run: python utils/fix_toc.py | |
| # `徽章信息` `帮助信息` 需要从修复toc之后提取脚本列表标记点. | |
| - name: 徽章信息 | |
| run: python utils/update_shields.py | |
| - name: 帮助信息 | |
| run: python utils/update_help.py | |
| - name: 翻译脚本自述 | |
| run: python utils/translate_chinese_to_filelang.py | |
| - name: 设置机器人提交 | |
| run: | | |
| gpg --batch --import <(echo "${{ secrets.GPG_PRIVATE_KEY }}") | |
| git config --global commit.gpgsign true | |
| git config --global user.name 'ChinaGodBot' | |
| git config --global user.email "${{ secrets.GPG_PRIVATE_EMAIL }}" | |
| git config --global user.signingkey "${{ secrets.GPG_PRIVATE_ID }}" | |
| - name: 提交和推送更改 | |
| run: | | |
| git pull | |
| git add . | |
| COMMIT_MESSAGE="docs(sync): 🤖 同步" | |
| # docs/[lang]/readme.md | |
| if git status --short | grep -q "docs/.*/README.md"; then | |
| if git status --short | grep -q "README_"; then | |
| COMMIT_MESSAGE+=" [\`docs/[lang]/README.md\`]" | |
| else | |
| COMMIT_MESSAGE+=" [\`[lang]/README.md\`]" | |
| fi | |
| fi | |
| # 脚本自述 | |
| if git status --short | grep -q "README_"; then | |
| if git status --short | grep -q "docs/.*/README.md"; then | |
| COMMIT_MESSAGE+=" [\`[script]/README_[lang].md\`]" | |
| else | |
| COMMIT_MESSAGE+=" [\`README_[lang].md\`]" | |
| fi | |
| fi | |
| git commit -n -m "$COMMIT_MESSAGE" || true | |
| git push | |
| if [ $? -ne 0 ]; then | |
| git pull --rebase | |
| git push | |
| fi |