Repository navigation
docs: 각 챕터 README 작성 #9
This file contains hidden or 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: 📊 진행률 업데이트 | ||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: write | ||
| pull-requests: read | ||
| jobs: | ||
| update-progress: | ||
| if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: 진행률 계산 및 README 업데이트 | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| // 스터디원 정보 | ||
| const members = { | ||
| 'jihostudy': '김지호', | ||
| 'hyeonbinHur': '허현빈', | ||
| 'yeyounging': '공예영' | ||
| }; | ||
| // 챕터 정보 (1-16장) | ||
| const chapters = ['1장', '2장', '3장', '4장', '5장', '6장', '7장', '8장', '9장', '10장', '11장', '12장', '13장', '14장', '15장', '16장']; | ||
| // 각 멤버의 챕터별 완료 상황 추적 | ||
| const progress = {}; | ||
| Object.keys(members).forEach(username => { | ||
| progress[username] = {}; | ||
| chapters.forEach(chapter => { | ||
| progress[username][chapter] = false; | ||
| }); | ||
| }); | ||
| // 파일 시스템에서 학습 노트 확인 | ||
| function checkDirectory(dir) { | ||
| if (!fs.existsSync(dir)) return; | ||
| const items = fs.readdirSync(dir, { withFileTypes: true }); | ||
| for (const item of items) { | ||
| const fullPath = path.join(dir, item.name); | ||
| if (item.isDirectory()) { | ||
| // 챕터 폴더인지 확인 (예: "1장", "2장") | ||
| if (chapters.includes(item.name)) { | ||
| const chapterFiles = fs.readdirSync(fullPath); | ||
| // 각 멤버의 파일이 있는지 확인 | ||
| Object.keys(members).forEach(username => { | ||
| const hasFile = chapterFiles.some(file => | ||
| file.toLowerCase().includes(username.toLowerCase()) || | ||
| file.toLowerCase().includes(members[username]) | ||
| ); | ||
| if (hasFile) { | ||
| progress[username][item.name] = true; | ||
| } | ||
| }); | ||
| } | ||
| // 재귀적으로 하위 디렉토리 확인 | ||
| checkDirectory(fullPath); | ||
| } | ||
| } | ||
| } | ||
| checkDirectory('.'); | ||
| // 진행률 테이블 생성 (드롭다운으로 감싸기) | ||
| let progressTable = '\n## 📈 전체 학습 진행률\n\n'; | ||
| progressTable += '<details>\n'; | ||
| progressTable += '<summary>📊 챕터별 진행 현황 보기</summary>\n\n'; | ||
| progressTable += '| 챕터 | 김지호 | 허현빈 | 공예영 |\n'; | ||
| progressTable += '| --- | :---: | :---: | :---: |\n'; | ||
| chapters.forEach(chapter => { | ||
| progressTable += `| ${chapter} `; | ||
| progressTable += `| ${progress['jihostudy'][chapter] ? '✅' : '⬜️'} `; | ||
| progressTable += `| ${progress['hyeonbinHur'][chapter] ? '✅' : '⬜️'} `; | ||
| progressTable += `| ${progress['yeyounging'][chapter] ? '✅' : '⬜️'} |\n`; | ||
| }); | ||
| // 전체 진행률 계산 | ||
| progressTable += '\n**전체 진행률**\n\n'; | ||
| Object.keys(members).forEach(username => { | ||
| const completed = Object.values(progress[username]).filter(v => v).length; | ||
| const total = chapters.length; | ||
| const percentage = Math.round((completed / total) * 100); | ||
| progressTable += `- ${members[username]}: ${completed}/${total} (${percentage}%)\n`; | ||
| }); | ||
| progressTable += '\n</details>\n\n---\n'; | ||
| // README.md 읽기 | ||
| let readme = fs.readFileSync('README.md', 'utf8'); | ||
| // 기존 진행률 섹션 제거 (있다면) | ||
| const progressRegex = /\n## 📈 학습 진행률\n[\s\S]*?\n---\n/; | ||
| if (progressRegex.test(readme)) { | ||
| readme = readme.replace(progressRegex, ''); | ||
| } | ||
| // 스터디 인원 섹션 앞에 진행률 추가 | ||
| const studyMemberSection = '# 스터디 인원'; | ||
| if (readme.includes(studyMemberSection)) { | ||
| readme = readme.replace(studyMemberSection, progressTable + studyMemberSection); | ||
| } else { | ||
| // 스터디 인원 섹션이 없으면 맨 끝에 추가 | ||
| readme += '\n' + progressTable; | ||
| } | ||
| // README.md 업데이트 | ||
| fs.writeFileSync('README.md', readme); | ||
| console.log('✅ 진행률 업데이트 완료!'); | ||
| - name: 변경사항 커밋 및 푸시 | ||
| run: | | ||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --local user.name "github-actions[bot]" | ||
| git add README.md | ||
| if git diff --staged --quiet; then | ||
| echo "변경사항 없음" | ||
| else | ||
| git commit -m "📊 학습 진행률 자동 업데이트" | ||
| git push | ||
| fi | ||
| <<<<<<< Updated upstream | ||
| ======= | ||
| >>>>>>> Stashed changes | ||