Update Rename and Commit Markdown Files 수정 중 #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 브랜치로 푸시 |