Wiki Fetch & Update #1414
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: Wiki Fetch & Update | |
| on: | |
| schedule: | |
| - cron: '0 */1 * * *' | |
| # 用户 push 触发,排除脚本写入的 data 目录 | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - 'data/**' | |
| - 'README.md' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| fetch-wiki: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: true | |
| - name: Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Install dependencies | |
| run: bun install --production | |
| - name: Fetch and extract Wiki pages | |
| timeout-minutes: 1 | |
| env: | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: bun begin | |
| # 新增:更新 README 时间戳并清理旧日志 | |
| - name: Update README Timestamp | |
| run: | | |
| # 设置时区为东八区(北京时间) | |
| export TZ='Asia/Shanghai' | |
| CURRENT_TIME=$(date "+%Y-%m-%d %H:%M:%S") | |
| sed -i '/更新于/d' README.md | |
| echo -e "更新于 $CURRENT_TIME" >> README.md | |
| - name: Commit & Push generated files | |
| # 只要不是bot递归触发都允许推送 | |
| if: ${{ github.actor != 'github-actions[bot]' }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| # 检查是否有文件变化,如果有则提交 | |
| git diff --cached --quiet || git commit -m "chore: wiki update & readme timestamp [skip ci]" | |
| git push |