-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (126 loc) · 5.54 KB
/
update-profile.yml
File metadata and controls
148 lines (126 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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 + Development 통합
CS_TOTAL=$((CS + ALGO + DEV))
# iOS + Swift 통합
IOS_TOTAL=$((IOS + SWIFT))
# Cross Platform 통합
CROSS_TOTAL=$((FLUTTER + RN))
# Mobile 전체
MOBILE_TOTAL=$((IOS_TOTAL + ANDROID + CROSS_TOTAL))
# README 업데이트할 내용 생성 (계층 구조)
cat > /tmp/til_stats.txt << EOF
_${TOTAL} TILs_
- Mobile: ${MOBILE_TOTAL}
- iOS: ${IOS_TOTAL}
- Android: ${ANDROID}
- Cross Platform: ${CROSS_TOTAL}
- Flutter: ${FLUTTER}
- React Native: ${RN}
- Computer Science: ${CS_TOTAL}
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