Skip to content

Commit 9478334

Browse files
authored
Merge pull request #6 from Spark0618/Spark0618-wp
tranform push_wp.yml into git diff version and create ai/test.md
2 parents 46d973b + 95840b0 commit 9478334

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/push_wp.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ jobs:
1818
uses: actions/setup-python@v5
1919
with:
2020
python-version: '3.x'
21-
- name: Get added files
21+
- name: Get added md files
2222
run: |
23-
# 先合并所有 commit 的 added
24-
FILES=$(jq -c '[.commits[] | (.added // [])[]]' <<< '${{ toJson(github.event) }}')
25-
echo "COMMIT_FILES=$FILES" >> $GITHUB_ENV
23+
git fetch origin main
24+
# 获取本次 push 中所有新增文件(A = Added)
25+
FILES=$(git diff --name-only --diff-filter=A origin/main~1..origin/main | grep '^docs/.*\.md$' || true)
26+
# 转成 JSON 数组
27+
FILES_JSON=$(jq -R -s -c 'split("\n")[:-1]' <<< "$FILES")
28+
echo "COMMIT_FILES=$FILES_JSON" >> $GITHUB_ENV
2629
- name: Update schedule JSON
2730
env:
2831
COMMITTER_NAME: ${{ github.actor }}

docs/ai/test.md

Whitespace-only changes.

scripts/update_calendar_on_push.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,16 @@ def to_mkdocs_url(path):
6767

6868
# 写回
6969
os.makedirs(os.path.dirname(schedule_file), exist_ok=True)
70+
# with open(schedule_file, 'w', encoding='utf-8') as f:
71+
# json.dump(events, f, ensure_ascii=False, indent=2)
72+
73+
# 手动写,保证单个字典不换行,字典之间换行
7074
with open(schedule_file, 'w', encoding='utf-8') as f:
71-
json.dump(events, f, ensure_ascii=False, indent=2)
75+
f.write('[\n')
76+
for i, ev in enumerate(events):
77+
json.dump(ev, f, ensure_ascii=False, separators=(',', ':'))
78+
if i < len(events) - 1:
79+
f.write(',\n')
80+
else:
81+
f.write('\n')
82+
f.write(']')

0 commit comments

Comments
 (0)