-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.37 KB
/
Rename and Commit Markdown Files.yml
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
name: Rename and Commit Markdown Files
on:
push:
branches:
- main # main 브랜치에 푸시될 때 워크플로우 트리거
workflow_dispatch: # 수동으로 워크플로우를 실행할 수 있는 옵션
schedule:
- cron: '17 15 * * *' # 매일 오전 10시 40분에 실행
jobs:
process-markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITBOOKKEY }}
fetch-depth: 0
ref: main
- name: Rename Markdown files
run: |
for file in developLog/*.md; do
# 첫 번째 H1 제목을 추출하여 제목으로 사용
title=$(grep -m 1 '^# ' "$file" | sed 's/^# //')
if [ -n "$title" ]; then
# 새 파일명을 제목을 기반으로 생성
new_filename="developLog/$title.md"
# 파일 이름이 동일한 경우에는 mv 명령을 건너뜁니다
if [ "$file" != "$new_filename" ]; then
mv "$file" "$new_filename"
fi
fi
done
- name: Commit changes
run: |
git add .
git config user.email "[email protected]"
git config user.name "GoldenPearls"
git commit -m "Rename Markdown files based on h1 titles"
git push origin main # 변경사항을 main 브랜치로 푸시