한글변환 부분 #44
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: # 수동으로 워크플로우를 실행할 수 있는 옵션 | |
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: Set UTF-8 Encoding | |
run: | | |
export LC_CTYPE="UTF-8" # UTF-8 인코딩을 명시적으로 설정 | |
- name: Rename and Update Markdown files | |
run: | | |
for file in $(find developLog -type f -name '*.md'); do | |
# 파일의 디렉토리와 파일명 추출 | |
dir=$(dirname "$file") | |
base_name=$(basename "$file" .md) | |
# 첫 번째 H1 제목을 추출하여 제목으로 사용 | |
title=$(grep -m 1 '^#' "$file" | sed 's/^# //') | |
if [ -n "$title" ]; then | |
# 새 파일명을 디렉토리 경로를 유지하면서 제목을 기반으로 생성 | |
new_filename="$dir/$title.md" | |
# 파일 이름이 동일한 경우에는 mv 명령을 건너뜁니다 | |
if [ "$file" != "$new_filename" ]; then | |
echo "Renaming $file to $new_filename" | |
mv "$file" "$new_filename" | |
else | |
echo "No rename needed for $file" | |
fi | |
else | |
echo "No valid title found in $file, skipping." | |
fi | |
done | |
- name: Commit changes | |
run: | | |
git add -A # 모든 변경사항 추가 | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git diff --staged --quiet || git commit -m "Rename and update Markdown files based on h1 titles" | |
git push https://${{ secrets.GITBOOKKEY }}@github.com/GoldenPearls/gitBook.git # 변경사항을 main 브랜치로 푸시 |