61 lines
2.1 KiB
YAML
61 lines
2.1 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 }}
|
|
COMMIT_MSG: ${{ gitea.event.head_commit.message }}
|
|
run: |
|
|
set -eu
|
|
SHORT_SHA="${SHA:0:7}"
|
|
STATUS_URL="https://status.gitea.pitap.at/${REPO}/actions/runs/${RUN_NUMBER}"
|
|
|
|
# 이벤트에서 못 받았으면 (수동 trigger 등) git에서 시도, 그것도 실패하면 fallback
|
|
if [ -z "${COMMIT_MSG:-}" ]; then
|
|
COMMIT_MSG="$(git log -1 --pretty=format:%s 2>/dev/null || echo '(no message)')"
|
|
fi
|
|
|
|
# 멀티라인 커밋 메시지면 첫 줄만
|
|
COMMIT_MSG="$(printf '%s' "$COMMIT_MSG" | head -n1)"
|
|
|
|
HEADER_TEXT="🚀 배포 시작 — ${REPO}"
|
|
|
|
PAYLOAD=$(jq -n \
|
|
--arg repo "$REPO" \
|
|
--arg branch "$BRANCH" \
|
|
--arg msg "$COMMIT_MSG" \
|
|
--arg actor "$ACTOR" \
|
|
--arg sturl "$STATUS_URL" \
|
|
'{
|
|
text: ("🚀 " + $repo + " 배포 시작"),
|
|
blocks: [
|
|
{type:"section", text:{type:"mrkdwn",
|
|
text: ("🚀 *" + $repo + "* 배포 시작")}},
|
|
{type:"context", elements:[
|
|
{type:"mrkdwn",
|
|
text: ($branch + " · " + $msg + " · " + $actor + " <" + $sturl)}
|
|
]},
|
|
{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" |