[UPDATE] Flutter/RN 각각의 숫자 표시 #12
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: Update Profile README | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '**.md' | ||
| jobs: | ||
| update-readme: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout TIL repository | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| token: ${{ secrets.PROFILE_UPDATE_TOKEN }} | ||
| path: TIL | ||
| - name: Count markdown files by category | ||
| id: count | ||
| run: | | ||
| cd TIL | ||
| # 각 카테고리별 아티클 수 카운트 (README, MIGRATION_LOG 제외) | ||
| ios_count=$(find Mobile_01_iOS -name "*.md" -type f ! -name "README.md" ! -name "MIGRATION_LOG*" 2>/dev/null | wc -l | xargs) | ||
| android_count=$(find Mobile_02_Android -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| flutter_count=$(find Mobile_03_Flutter -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| rn_count=$(find Mobile_04_ReactNative -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| cs_count=$(find ComputerScience -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| algo_count=$(find Algorithm -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| dev_count=$(find Development -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| swift_count=$(find Lang-Swift -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs) | ||
| # 전체 아티클 수 (README 제외, MIGRATION_LOG 제외) | ||
| total_count=$(find . -name "*.md" -type f ! -name "README.md" ! -name "MIGRATION_LOG*" | wc -l | xargs) | ||
| echo "count=$total_count" >> $GITHUB_OUTPUT | ||
| echo "ios=$ios_count" >> $GITHUB_OUTPUT | ||
| echo "android=$android_count" >> $GITHUB_OUTPUT | ||
| echo "flutter=$flutter_count" >> $GITHUB_OUTPUT | ||
| echo "rn=$rn_count" >> $GITHUB_OUTPUT | ||
| echo "cs=$cs_count" >> $GITHUB_OUTPUT | ||
| echo "algo=$algo_count" >> $GITHUB_OUTPUT | ||
| echo "dev=$dev_count" >> $GITHUB_OUTPUT | ||
| echo "swift=$swift_count" >> $GITHUB_OUTPUT | ||
| echo "Total: $total_count articles" | ||
| echo "iOS: $ios_count, Flutter: $flutter_count, React Native: $rn_count" | ||
| - name: Update TIL README | ||
| run: | | ||
| cd TIL | ||
| TOTAL="${{ steps.count.outputs.count }}" | ||
| IOS="${{ steps.count.outputs.ios }}" | ||
| ANDROID="${{ steps.count.outputs.android }}" | ||
| FLUTTER="${{ steps.count.outputs.flutter }}" | ||
| RN="${{ steps.count.outputs.rn }}" | ||
| CS="${{ steps.count.outputs.cs }}" | ||
| ALGO="${{ steps.count.outputs.algo }}" | ||
| DEV="${{ steps.count.outputs.dev }}" | ||
| SWIFT="${{ steps.count.outputs.swift }}" | ||
| # ComputerScience + Algorithm 통합 | ||
| CS_TOTAL=$((CS + ALGO)) | ||
| # iOS + Swift 통합 | ||
| IOS_TOTAL=$((IOS + SWIFT)) | ||
| # 카테고리 수 계산 (0이 아닌 카테고리만) | ||
| # Flutter / RN은 하나의 카테고리로 계산 | ||
| categories=0 | ||
| [ "$IOS_TOTAL" -gt 0 ] && ((categories++)) | ||
| [ "$ANDROID" -gt 0 ] && ((categories++)) | ||
| [ "$FLUTTER" -gt 0 ] || [ "$RN" -gt 0 ] && ((categories++)) | ||
| [ "$CS_TOTAL" -gt 0 ] && ((categories++)) | ||
| [ "$DEV" -gt 0 ] && ((categories++)) | ||
| # README 업데이트할 내용 생성 | ||
| cat > /tmp/til_stats.txt << EOF | ||
| _${TOTAL} TILs across ${categories} categories_ | ||
| - iOS: ${IOS_TOTAL} | ||
| - Flutter / React Native: ${FLUTTER} / ${RN} | ||
| - Computer Science: ${CS_TOTAL} | ||
| - Development: ${DEV} | ||
| - Android: ${ANDROID} | ||
| EOF | ||
| # 기존 "_숫자 TILs" 라인부터 다음 빈 줄 또는 --- 까지를 새 내용으로 교체 | ||
| awk ' | ||
| /_[0-9]+ TILs/ { | ||
| system("cat /tmp/til_stats.txt") | ||
| # 다음 빈 줄이나 --- 까지 스킵 | ||
| getline | ||
| while (getline && $0 != "" && $0 !~ /^---/) {} | ||
| if ($0 == "" || $0 ~ /^---/) print $0 | ||
| next | ||
| } | ||
| {print} | ||
| ' README.md > README.md.tmp | ||
| mv README.md.tmp README.md | ||
| echo "Updated TIL README with category breakdown" | ||
| - name: Commit and push TIL README if changed | ||
| run: | | ||
| cd TIL | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| if git diff --quiet; then | ||
| echo "No changes to commit in TIL README" | ||
| else | ||
| git add README.md | ||
| git commit -m "[AUTO] Update TIL article count to ${{ steps.count.outputs.count }}" | ||
| git push | ||
| echo "TIL README changes committed and pushed" | ||
| fi | ||
| - name: Checkout profile repository | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: isGeekCode/isGeekCode | ||
| token: ${{ secrets.PROFILE_UPDATE_TOKEN }} | ||
| path: profile | ||
| - name: Update Profile README | ||
| run: | | ||
| cd profile | ||
| ARTICLE_COUNT="${{ steps.count.outputs.count }}" | ||
| # Profile README.md에서 "TIL (숫자 articles)" 패턴을 찾아서 업데이트 | ||
| sed -i "s/TIL ([0-9]* articles)/TIL ($ARTICLE_COUNT articles)/g" README.md | ||
| echo "Updated Profile README article count to: $ARTICLE_COUNT" | ||
| - name: Commit and push Profile README if changed | ||
| run: | | ||
| cd profile | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| if git diff --quiet; then | ||
| echo "No changes to commit in Profile README" | ||
| else | ||
| git add README.md | ||
| git commit -m "[AUTO] Update TIL article count to ${{ steps.count.outputs.count }}" | ||
| git push | ||
| echo "Profile README changes committed and pushed" | ||
| fi | ||