GITBOOK-81: 컴퓨터 구조와 운영체제를 알아야 하는 이유 - 운영체제 개념 추가 및 확인용 #109
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 | |
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" | |
- name: Rename and Update Markdown files (excluding README and SUMMARY) | |
run: | | |
for file in $(find developLog -type f -name '*.md' ! -name 'README.md' ! -name 'SUMMARY.md'); do | |
title=$(grep -m 1 '^#' "$file" | sed 's/^# //') | |
if [ -n "$title" ]; then | |
dir=$(dirname "$file") | |
new_filename="$dir/$title.md" | |
new_dir=$(dirname "$new_filename") | |
mkdir -p "$new_dir" | |
if [ "$file" != "$new_filename" ]; then | |
echo "Renaming $file to $new_filename" | |
mv "$file" "$new_filename" | |
else | |
echo "Updating timestamp for $file" | |
touch "$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 (excluding README and SUMMARY)" | |
git push https://${{ secrets.GITBOOKKEY }}@github.com/GoldenPearls/gitBook.git |