From ca4ba9889cac28135a48e2c58a2544739c0f9b16 Mon Sep 17 00:00:00 2001 From: "kihwan.song" Date: Wed, 29 Apr 2026 09:44:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8A=AC=EB=9E=99=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EC=9B=B9=ED=9B=85=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notify-slack/action.yml | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 notify-slack/action.yml diff --git a/notify-slack/action.yml b/notify-slack/action.yml new file mode 100644 index 0000000..29b9f8b --- /dev/null +++ b/notify-slack/action.yml @@ -0,0 +1,53 @@ +name: Slack 배포 시작 알림 +description: 배포 시작을 Slack으로 전송하는 스크립트 +inputs: + webhook-url: + required: true +runs: + using: composite + steps: + - shell: bash + env: + WEBHOOK_URL: ${{ inputs.webhook-url }} + REPO: ${{ gitea.repository }} + BRANCH: ${{ gitea.ref_name }} + ACTOR: ${{ gitea.actor }} + RUN_ID: ${{ gitea.run_id }} + SHA: ${{ gitea.sha }} + run: | + set -eu + SHORT_SHA="${SHA:0:7}" + STATUS_URL="https://status.gitea.sample.com/${REPO}/actions/runs/${RUN_ID}" + COMMIT_MSG="$(git log -1 --pretty=format:%s 2>/dev/null || echo '(no message)')" + HEADER_TEXT="🚀 배포 시작 — ${REPO}" + + PAYLOAD=$(jq -n \ + --arg header "$HEADER_TEXT" \ + --arg branch "$BRANCH" \ + --arg sha "$SHORT_SHA" \ + --arg actor "$ACTOR" \ + --arg msg "$COMMIT_MSG" \ + --arg sturl "$STATUS_URL" \ + '{ + text: $header, + blocks: [ + {type:"header", text:{type:"plain_text", text:$header, emoji:true}}, + {type:"section", fields:[ + {type:"mrkdwn", text:("*브랜치*\n`" + $branch + "`")}, + {type:"mrkdwn", text:("*커밋*\n`" + $sha + "` " + $msg)}, + {type:"mrkdwn", text:("*실행자*\n" + $actor)} + ]}, + {type:"actions", elements:[ + {type:"button", + text:{type:"plain_text", text:"📊 배포 상태 보기", emoji:true}, + url:$sturl, + style:"primary"} + ]} + ] + }') + + echo "$PAYLOAD" | curl -sS --fail-with-body \ + -X POST \ + -H 'Content-Type: application/json; charset=utf-8' \ + --data @- \ + "$WEBHOOK_URL" \ No newline at end of file