Skip to content

Commit 5a5c0e4

Browse files
committed
chore: 배포 Slack 알림 추가
1 parent 1b16d8c commit 5a5c0e4

1 file changed

Lines changed: 85 additions & 1 deletion

File tree

.github/workflows/cicd-workflow.yml

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,88 @@ jobs:
199199
task-definition: ${{ steps.task-def-develop.outputs.task-definition }} # ECS 태스크 정의 파일을 지정합니다.
200200
service: ${{ secrets.ECS_SERVICE_NAME_DEV }}
201201
cluster: ${{ secrets.ECS_CLUSTER_NAME }}
202-
wait-for-service-stability: true # 서비스가 안정화될 때까지 대기합니다.
202+
wait-for-service-stability: true # 서비스가 안정화될 때까지 대기합니다.
203+
204+
# 11. 배포 알림 메세지 설정
205+
- name: Set Slack message based on branch
206+
id: set-slack-message
207+
run: |
208+
if [[ "${{ github.ref_name }}" == "develop" ]]; then
209+
echo "SLACK_MESSAGE=✅ 개발계(develop) 배포 완료 🎉" >> $GITHUB_ENV
210+
elif [[ "${{ github.ref_name }}" == "release" ]]; then
211+
echo "SLACK_MESSAGE=🚀 운영계(release) 배포 완료!" >> $GITHUB_ENV
212+
else
213+
echo "SLACK_MESSAGE=⚙️ '${{ github.ref_name }}' 브랜치로 배포되었습니다." >> $GITHUB_ENV
214+
fi
215+
216+
# 12. Slack 배포 성공 알림(개발, 운영 서버)
217+
- name: Notify Slack - release
218+
if: success()
219+
id: slack-success
220+
uses: slackapi/slack-github-action@v1.24.0
221+
with:
222+
payload: |
223+
{
224+
"channel": "#server-deploy",
225+
"attachments": [
226+
{
227+
"color": "#36a64f",
228+
"title": "🔔 ${{ github.repository }} 배포 알림",
229+
"title_link": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
230+
"text": "${{ env.SLACK_MESSAGE }}",
231+
"fields": [
232+
{
233+
"title": "브랜치",
234+
"value": "${{ github.ref_name }}",
235+
"short": true
236+
},
237+
{
238+
"title": "배포자",
239+
"value": "${{ github.actor }}",
240+
"short": true
241+
},
242+
{
243+
"title": "커밋 메시지",
244+
"value": "${{ github.event.head_commit.message }}",
245+
"short": false
246+
}
247+
]
248+
}
249+
]
250+
}
251+
env:
252+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOY_BOT_WEBHOOK_URL }}
253+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
254+
255+
# 13. Slack 배포 실패 알림(개발, 운영 서버)
256+
- name: Notify Slack - failure
257+
if: failure() # 이 스텝은 job 실패 시에만 실행됨
258+
uses: slackapi/slack-github-action@v1.24.0
259+
with:
260+
payload: |
261+
{
262+
"channel": "#server-deploy",
263+
"attachments": [
264+
{
265+
"color": "#ff0000", # 실패는 빨간색
266+
"title": "🚨 배포 실패: ${{ github.repository }}",
267+
"title_link": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
268+
"text": "${{ github.ref_name }} 브랜치에 배포 실패 ❌",
269+
"fields": [
270+
{
271+
"title": "브랜치",
272+
"value": "${{ github.ref_name }}",
273+
"short": true
274+
},
275+
{
276+
"title": "커밋 메시지",
277+
"value": "${{ github.event.head_commit.message }}",
278+
"short": false
279+
}
280+
]
281+
}
282+
]
283+
}
284+
env:
285+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOY_BOT_WEBHOOK_URL }}
286+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

0 commit comments

Comments
 (0)