Skip to content

Commit 485b5c6

Browse files
authored
Add workflow to sync docs to root on push
This workflow automates the synchronization of documentation files from the 'docs' directory to the root of the repository whenever there is a push to the main branch.
1 parent dab9ecf commit 485b5c6

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Sync docs to root
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
sync:
12+
# 防止机器人提交触发自身循环
13+
if: github.actor != 'github-actions[bot]'
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout main
18+
uses: actions/checkout@v4
19+
with:
20+
ref: main
21+
fetch-depth: 0
22+
23+
- name: Configure git
24+
run: |
25+
git config user.name "github-actions[bot]"
26+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
27+
28+
- name: Copy docs to root
29+
run: |
30+
# 清除根工作区中除 .git 外的文件(小心:如果你想保留某些文件,请调整此处的删除/排除策略)
31+
shopt -s extglob
32+
rm -rf !( .git )
33+
# 将 docs 内容复制到根目录
34+
cp -a docs/. ./
35+
# 如果你希望保留 .github 或其他目录,请改用 rsync 排除这些目录
36+
# rsync -av --exclude='.git' --exclude='.github' docs/ ./
37+
38+
- name: Commit & push if changed
39+
run: |
40+
git add -A
41+
if git diff --staged --quiet; then
42+
echo "No changes to commit"
43+
exit 0
44+
fi
45+
git commit -m "Sync docs -> root (automated) [ci skip]"
46+
git push origin main

0 commit comments

Comments
 (0)