-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.26 KB
/
Copy pathsync-posts.yml
File metadata and controls
51 lines (43 loc) · 1.26 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
# 从 posts/*.md 的 YAML 头生成 posts.json + 整理附件
name: Sync Posts
on:
push:
branches:
- main
paths:
- "posts/**/*.md"
- "posts/**/*"
- "scripts/build_posts_index.py"
- "scripts/organize_resources.py"
- ".github/workflows/sync-posts.yml"
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install --no-cache-dir pyyaml
- name: Organize resources
run: python scripts/organize_resources.py
- name: Build posts.json
run: python scripts/build_posts_index.py
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add posts.json posts/ resource/
if git diff --cached --quiet; then
echo "No changes"
exit 0
fi
git commit -m "chore: sync posts and organize resources"
git pull --rebase origin main
git push origin main