Skip to content

Commit cd2ba91

Browse files
committed
[UPDATE] 카테고리별 아티클 수 표시 기능 추가
- iOS, Flutter, React Native 등 카테고리별 통계 표시 - 전체 아티클 수와 카테고리 수 자동 계산 - README에 '_숫자 TILs across 숫자 categories_' 형식으로 표시 - 각 카테고리별 아티클 수를 내림차순으로 정렬
1 parent 54fe70e commit cd2ba91

1 file changed

Lines changed: 75 additions & 8 deletions

File tree

.github/workflows/update-profile.yml

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,90 @@ jobs:
1818
token: ${{ secrets.PROFILE_UPDATE_TOKEN }}
1919
path: TIL
2020

21-
- name: Count markdown files
21+
- name: Count markdown files by category
2222
id: count
2323
run: |
2424
cd TIL
25-
count=$(find . -name "*.md" -type f ! -name "README.md" | wc -l)
26-
echo "count=$count" >> $GITHUB_OUTPUT
27-
echo "Total articles: $count"
25+
26+
# 각 카테고리별 아티클 수 카운트 (README, MIGRATION_LOG 제외)
27+
ios_count=$(find Mobile_01_iOS -name "*.md" -type f ! -name "README.md" ! -name "MIGRATION_LOG*" 2>/dev/null | wc -l | xargs)
28+
android_count=$(find Mobile_02_Android -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
29+
flutter_count=$(find Mobile_03_Flutter -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
30+
rn_count=$(find Mobile_04_ReactNative -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
31+
cs_count=$(find ComputerScience -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
32+
algo_count=$(find Algorithm -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
33+
dev_count=$(find Development -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
34+
swift_count=$(find Lang-Swift -name "*.md" -type f ! -name "README.md" 2>/dev/null | wc -l | xargs)
35+
36+
# 전체 아티클 수 (README 제외, MIGRATION_LOG 제외)
37+
total_count=$(find . -name "*.md" -type f ! -name "README.md" ! -name "MIGRATION_LOG*" | wc -l | xargs)
38+
39+
echo "count=$total_count" >> $GITHUB_OUTPUT
40+
echo "ios=$ios_count" >> $GITHUB_OUTPUT
41+
echo "android=$android_count" >> $GITHUB_OUTPUT
42+
echo "flutter=$flutter_count" >> $GITHUB_OUTPUT
43+
echo "rn=$rn_count" >> $GITHUB_OUTPUT
44+
echo "cs=$cs_count" >> $GITHUB_OUTPUT
45+
echo "algo=$algo_count" >> $GITHUB_OUTPUT
46+
echo "dev=$dev_count" >> $GITHUB_OUTPUT
47+
echo "swift=$swift_count" >> $GITHUB_OUTPUT
48+
49+
echo "Total: $total_count articles"
50+
echo "iOS: $ios_count, Flutter: $flutter_count, React Native: $rn_count"
2851
2952
- name: Update TIL README
3053
run: |
3154
cd TIL
32-
ARTICLE_COUNT="${{ steps.count.outputs.count }}"
55+
TOTAL="${{ steps.count.outputs.count }}"
56+
IOS="${{ steps.count.outputs.ios }}"
57+
ANDROID="${{ steps.count.outputs.android }}"
58+
FLUTTER="${{ steps.count.outputs.flutter }}"
59+
RN="${{ steps.count.outputs.rn }}"
60+
CS="${{ steps.count.outputs.cs }}"
61+
ALGO="${{ steps.count.outputs.algo }}"
62+
DEV="${{ steps.count.outputs.dev }}"
63+
SWIFT="${{ steps.count.outputs.swift }}"
64+
65+
# 카테고리 수 계산 (0이 아닌 카테고리만)
66+
categories=0
67+
[ "$IOS" -gt 0 ] && ((categories++))
68+
[ "$ANDROID" -gt 0 ] && ((categories++))
69+
[ "$FLUTTER" -gt 0 ] && ((categories++))
70+
[ "$RN" -gt 0 ] && ((categories++))
71+
[ "$CS" -gt 0 ] && ((categories++))
72+
[ "$ALGO" -gt 0 ] && ((categories++))
73+
[ "$DEV" -gt 0 ] && ((categories++))
74+
[ "$SWIFT" -gt 0 ] && ((categories++))
75+
76+
# README 업데이트할 내용 생성
77+
cat > /tmp/til_stats.txt << EOF
78+
_${TOTAL} TILs across ${categories} categories_
79+
- iOS: ${IOS} articles
80+
- Flutter: ${FLUTTER} articles
81+
- ComputerScience: ${CS} articles
82+
- Algorithm: ${ALGO} articles
83+
- Development: ${DEV} articles
84+
- Swift: ${SWIFT} articles
85+
- React Native: ${RN} articles
86+
- Android: ${ANDROID} articles
87+
EOF
88+
89+
# 기존 "_숫자 TILs" 라인부터 다음 빈 줄 또는 --- 까지를 새 내용으로 교체
90+
awk '
91+
/_[0-9]+ TILs/ {
92+
system("cat /tmp/til_stats.txt")
93+
# 다음 빈 줄이나 --- 까지 스킵
94+
getline
95+
while (getline && $0 != "" && $0 !~ /^---/) {}
96+
if ($0 == "" || $0 ~ /^---/) print $0
97+
next
98+
}
99+
{print}
100+
' README.md > README.md.tmp
33101
34-
# TIL README.md에서 "_숫자 TILs and counting..._" 패턴을 찾아서 업데이트
35-
sed -i "s/_[0-9]* TILs and counting.../_$ARTICLE_COUNT TILs and counting.../g" README.md
102+
mv README.md.tmp README.md
36103
37-
echo "Updated TIL README article count to: $ARTICLE_COUNT"
104+
echo "Updated TIL README with category breakdown"
38105
39106
- name: Commit and push TIL README if changed
40107
run: |

0 commit comments

Comments
 (0)