Skip to content

Discussion Webhook #695

Discussion Webhook

Discussion Webhook #695

name: Discussion Webhook
on:
discussion:
types: [created, edited]
jobs:
notify_webhook:
runs-on: ubuntu-latest
env:
DISCUSSION_BODY: ${{ github.event.discussion.body }}
steps:
- name: Send Webhook on Discussion Creation or Edit
run: |
# 환경 변수에 저장된 DISCUSSION_BODY를 그대로 사용하여 CR 제거 및 JSON 인코딩
BODY=$(printf '%s' "$DISCUSSION_BODY" | tr -d '\r' | jq -Rs .)
JSON=$(jq -nc --arg event "${{ github.event.action }}" \
--arg number "${{ github.event.discussion.number }}" \
--arg url "${{ github.event.discussion.html_url }}" \
--arg title "${{ github.event.discussion.title }}" \
--arg user "${{ github.event.discussion.user.login }}" \
--arg created_at "${{ github.event.discussion.created_at }}" \
--arg updated_at "${{ github.event.discussion.updated_at }}" \
--argjson body "$BODY" \
'{event: $event, discussion_number: $number, discussion_url: $url, title: $title, user: $user, created_at: $created_at, updated_at: $updated_at, body: $body}')
curl -X POST "http://54.180.153.206:8080/api/github/webhook" \
-H "Content-Type: application/json" \
-d "$JSON"