Skip to content

Commit b2f400d

Browse files
committed
[ADD] GitHub Actions로 프로필 README 자동 업데이트 설정
- TIL 저장소에 push 시 자동으로 문서 개수 카운트 - isGeekCode/isGeekCode 프로필 README 자동 업데이트 - 변경사항 발생 시 자동 커밋 & 푸시
1 parent 47efb75 commit b2f400d

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Update Profile README
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**.md'
9+
10+
jobs:
11+
update-readme:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout TIL repository
16+
uses: actions/checkout@v3
17+
with:
18+
path: TIL
19+
20+
- name: Count markdown files
21+
id: count
22+
run: |
23+
cd TIL
24+
count=$(find . -name "*.md" -type f ! -name "README.md" | wc -l)
25+
echo "count=$count" >> $GITHUB_OUTPUT
26+
echo "Total articles: $count"
27+
28+
- name: Checkout profile repository
29+
uses: actions/checkout@v3
30+
with:
31+
repository: isGeekCode/isGeekCode
32+
token: ${{ secrets.PROFILE_UPDATE_TOKEN }}
33+
path: profile
34+
35+
- name: Update README
36+
run: |
37+
cd profile
38+
ARTICLE_COUNT="${{ steps.count.outputs.count }}"
39+
40+
# README.md에서 "TIL (숫자 articles)" 패턴을 찾아서 업데이트
41+
sed -i "s/TIL ([0-9]* articles)/TIL ($ARTICLE_COUNT articles)/g" README.md
42+
43+
echo "Updated article count to: $ARTICLE_COUNT"
44+
45+
- name: Commit and push if changed
46+
run: |
47+
cd profile
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
if git diff --quiet; then
52+
echo "No changes to commit"
53+
else
54+
git add README.md
55+
git commit -m "[AUTO] Update TIL article count to ${{ steps.count.outputs.count }}"
56+
git push
57+
echo "Changes committed and pushed"
58+
fi

0 commit comments

Comments
 (0)