[Feat] TIL 삭제 API 구현 #132
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: Discord Issue Notification | |
| on: | |
| issues: | |
| types: [opened, closed, reopened] | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Issue Notification to Discord | |
| env: | |
| DISCORD_ISSUES_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} | |
| ACTOR: ${{ github.actor }} | |
| REPO: ${{ github.repository }} | |
| ACTION: ${{ github.event.action }} | |
| ISSUE_NUMBER: ${{ github.event.issue.number }} | |
| ISSUE_TITLE: ${{ github.event.issue.title }} | |
| ISSUE_BODY: ${{ github.event.issue.body }} | |
| ISSUE_URL: ${{ github.event.issue.html_url }} | |
| DATE: ${{ github.event.issue.created_at }} | |
| run: | | |
| # 날짜 포맷 변환 (UTC → KST) | |
| FORMATTED_DATE=$(date -d "$DATE" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || date '+%Y-%m-%d %H:%M:%S') | |
| # 액션별 이모지/제목 | |
| if [ "$ACTION" = "opened" ]; then | |
| LABEL="🐛 [ISSUE OPEN]" | |
| elif [ "$ACTION" = "closed" ]; then | |
| LABEL="✅ [ISSUE CLOSED]" | |
| elif [ "$ACTION" = "reopened" ]; then | |
| LABEL="🔄 [ISSUE REOPENED]" | |
| fi | |
| # 이슈내용 (50자 제한) | |
| if [ -n "$ISSUE_BODY" ]; then | |
| BODY_TRIMMED=$(echo "$ISSUE_BODY" | head -c 50) | |
| ORIGINAL_LEN=$(echo -n "$ISSUE_BODY" | wc -c) | |
| if [ "$ORIGINAL_LEN" -gt 50 ]; then | |
| BODY_TRIMMED="${BODY_TRIMMED}..." | |
| fi | |
| fi | |
| # 이슈포럼 게시글 제목 | |
| THREAD_NAME="$LABEL #$ISSUE_NUMBER $ISSUE_TITLE" | |
| # 포럼 본문 내용 | |
| TEXT=$(printf "%s\n%s\n%s\n%s\n%s" \ | |
| "$LABEL **$REPO**" \ | |
| "👤 [작성자] $ACTOR" \ | |
| "📅 [날짜] $FORMATTED_DATE" \ | |
| "📝 [이슈] #$ISSUE_NUMBER $ISSUE_TITLE" \ | |
| "🗂 [Repository] $REPO") | |
| if [ -n "$BODY_TRIMMED" ]; then | |
| TEXT=$(printf "%s\n%s" "$TEXT" "💬 [내용] $BODY_TRIMMED") | |
| fi | |
| TEXT=$(printf "%s\n%s" "$TEXT" "🔗 $ISSUE_URL") | |
| # 포럼 채널용 JSON (thread_name 포함) | |
| jq -n \ | |
| --arg thread "$THREAD_NAME" \ | |
| --arg msg "$TEXT" \ | |
| '{thread_name: $thread, content: $msg}' | \ | |
| curl -X POST -H "Content-Type: application/json" -d @- "$DISCORD_ISSUES_WEBHOOK" |