Skip to content

GITBOOK-56: No subject #4

GITBOOK-56: No subject

GITBOOK-56: No subject #4

name: Rename and Commit Markdown Files
on:
push:
branches:
- main # main λΈŒλžœμΉ˜μ— ν‘Έμ‹œλ  λ•Œ μ›Œν¬ν”Œλ‘œμš° 트리거
workflow_dispatch: # μˆ˜λ™μœΌλ‘œ μ›Œν¬ν”Œλ‘œμš°λ₯Ό μ‹€ν–‰ν•  수 μžˆλŠ” μ˜΅μ…˜
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 config --local user.email "[email protected]"
git config --local user.name "GoldenPearls"
git add .
git commit -m "Rename Markdown files based on h1 titles"
git push origin main # 변경사항을 main 브랜치둜 ν‘Έμ‹œ