53 lines
1.8 KiB
YAML
53 lines
1.8 KiB
YAML
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_NUMBER: ${{ gitea.run_number }}
|
|
SHA: ${{ gitea.sha }}
|
|
run: |
|
|
set -eu
|
|
SHORT_SHA="${SHA:0:7}"
|
|
STATUS_URL="https://status.gitea.pitap.at/${REPO}/actions/runs/${RUN_NUMBER}"
|
|
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" |