큐레이션 수정 & 챗봇 이미지 적용 #40
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: Notify Discord on PR Merge to main | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| notify-discord: | |
| if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' | |
| runs-on: ubuntu-latest | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| # 개인 토큰 필요 시 아래 주석 해제 후 secrets에 등록 | |
| # PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| steps: | |
| - name: Get PR number | |
| run: echo "PR_NUM=${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
| - name: Fetch commits for PR | |
| id: fetch_commits | |
| run: | | |
| COMMITS_JSON=$(curl -sSL \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pulls/${{ env.PR_NUM }}/commits") | |
| echo "$COMMITS_JSON" > commits.json | |
| COMMITS_COUNT=$(echo "$COMMITS_JSON" | jq 'length') | |
| COMMITS_MSG=$(echo "$COMMITS_JSON" | jq -r '[.[] | "- [" + (.sha[:7]) + "](" + .html_url + ") " + .commit.message] | join("\n")') | |
| echo "COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV | |
| echo "COMMITS_MSG<<EOF" >> $GITHUB_ENV | |
| echo "$COMMITS_MSG" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Send Discord notification | |
| run: | | |
| USERNAME="${{ github.actor }}" | |
| NOW=$(date '+%Y-%m-%d %H:%M') | |
| JSON_PAYLOAD=$(jq -n --arg content "🚀 **배포 완료** (main 브랜치) | |
| 배포자: @$USERNAME | |
| 커밋 $COMMITS_COUNT개 포함 | |
| 배포 시간: $NOW | |
| 커밋 내역: | |
| $COMMITS_MSG" '{content: $content}') | |
| curl -H "Content-Type: application/json" \ | |
| -X POST \ | |
| -d "$JSON_PAYLOAD" \ | |
| "$DISCORD_WEBHOOK_URL" | |
| env: | |
| COMMITS_MSG: ${{ env.COMMITS_MSG }} |