Sync and Summarize FE News #22
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: Sync and Summarize FE News | |
| on: | |
| schedule: | |
| - cron: '0 0 10 * *' # 매월 10일 00:00 UTC (한국시간 오전 9시) | |
| workflow_dispatch: # 수동 실행도 가능 | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout forked repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| fetch-depth: 0 # merge를 위해 전체 히스토리 필요 | |
| - name: Set up Git | |
| run: | | |
| git config user.name "SuKyoung Shin" | |
| git config user.email "[email protected]" | |
| - name: Add upstream and fetch | |
| run: | | |
| git remote | grep upstream || git remote add upstream https://github.com/naver/fe-news | |
| git fetch upstream | |
| - name: 💥 기존 이슈 파일 삭제로 merge conflict 방지 | |
| run: | | |
| rm -f issues/*.md || true | |
| - name: Merge upstream changes | |
| run: | | |
| git checkout master | |
| git merge upstream/master --allow-unrelated-histories -m "Sync with upstream naver/fe-news" | |
| - name: Push changes | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: | | |
| git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }} master | |
| summarize: | |
| runs-on: ubuntu-latest | |
| needs: sync # sync 완료 후 실행 | |
| steps: | |
| - name: Get current year and month | |
| run: echo "YEAR_MONTH=$(date +'%Y-%m')" >> $GITHUB_ENV | |
| - name: Download FE News issue markdown | |
| run: | | |
| curl -s "https://raw.githubusercontent.com/naver/fe-news/master/issues/${YEAR_MONTH}.md" -o news.md | |
| - name: Extract top 10 items | |
| run: | | |
| grep '^-' news.md | head -n 10 > summary.txt | |
| - name: Send Telegram Summary | |
| run: | | |
| MONTH=$(date +'%m' | sed 's/^0*//')월 | |
| SUMMARY=$(cat summary.txt) | |
| MESSAGE=$(echo -e "📮 ${MONTH}의 Naver/FeNews가 방금 도착했어요!\n\n📰 ${MONTH} FE News 요약\n\n${SUMMARY}\n\n🔗 전체 보기: https://github.com/naver/fe-news/blob/master/issues/${YEAR_MONTH}.md") | |
| curl -s -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage \ | |
| --data-urlencode "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \ | |
| --data-urlencode "text=$MESSAGE" |