슬랙 메세지 웹훅 스크립트 추가
This commit is contained in:
53
notify-slack/action.yml
Normal file
53
notify-slack/action.yml
Normal file
@@ -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"
|
||||||
Reference in New Issue
Block a user