Repository navigation
74 lines (66 loc) · 2.32 KB
/
Copy pathexport.yml
File metadata and controls
74 lines (66 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Auto Export & Lint
# main 上唯一会改「机器人专属」入库文件的地方:
# - 重新生成 catalog.md
# - 把 log.d/ 碎片并入 log.md 顶部
# PR 不修改这两个文件(lint.yml 的 pr_derived_guard 会拦),所以这里的提交不会与任何 PR 冲突。
# 统计 JSON / 徽章 / Hero 数字已不入库,由 pages.yml 部署时生成。
on:
push:
branches: [main]
paths:
- 'wiki/**'
- 'roadmap/**'
- 'tech-map/**'
- 'references/**'
- 'log.d/**'
- 'scripts/generate_page_catalog.py'
- 'scripts/log_md.py'
workflow_dispatch:
# 串行执行,避免与并发 main 推送互相 cancel / 抢写导致 git push 被拒
concurrency:
group: auto-export-main
cancel-in-progress: false
permissions:
contents: write
jobs:
export:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
# 取最新 main 而非触发事件的 SHA:串行排队的后一轮能看到前一轮已并入的碎片
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Regenerate catalog and fold log fragments
run: |
python3 scripts/generate_page_catalog.py
python3 scripts/fold_log_fragments.py
- name: Commit
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A catalog.md log.md log.d/
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "chore: auto catalog + fold log.d [skip ci]"
# 与其他 PR 合并推送竞态时 rebase 重试;PR 不碰 catalog.md / log.md,rebase 不会冲突
for attempt in 1 2 3 4 5; do
if git push; then
echo "Pushed on attempt ${attempt}"
exit 0
fi
echo "Push rejected (attempt ${attempt}); rebase onto origin/main and retry"
git fetch origin main
git rebase origin/main
sleep $((attempt * 2))
done
echo "Failed to push after retries" >&2
exit 1