Rename Markdown files based on h1 titles #7
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 λΈλμΉλ‘ νΈμ |