Skip to content

Commit ad479dc

Browse files
committed
feat: 배포 시 슬랙 알림을 보내도록 수정
1 parent 3719364 commit ad479dc

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ jobs:
6363
cache: 'pnpm'
6464
cache-dependency-path: 'pnpm-lock.yaml'
6565

66+
- name: Get current repo name
67+
id: info
68+
run: echo "::set-output name=repository_name::$(echo ${{ github.repository }} | sed -e 's/${{ github.repository_owner }}\///')"
69+
6670
- name: Install project dependencies
6771
run: pnpm install --frozen-lockfile
6872

@@ -73,3 +77,68 @@ jobs:
7377
- run: aws s3 cp --recursive ./dist s3://${{ secrets[matrix.aws_s3_bucket_key] }}/
7478

7579
- run: aws cloudfront create-invalidation --distribution-id ${{ secrets[matrix.aws_cloudfront_distribution_key] }} --paths "/*"
80+
81+
# Notify to Slack (Success)
82+
- name: Notify deployment to Slack
83+
if: failure() || cancelled()
84+
uses: slackapi/[email protected]
85+
with:
86+
channel-id: ${{ vars.SLACK_DEPLOYMENT_ALERT_CHANNEL }}
87+
payload: |
88+
{
89+
"blocks": [
90+
{
91+
"type": "header",
92+
"text": {
93+
"type": "plain_text",
94+
"text": "${{ steps.info.outputs.repository_name }} 버전 배포 실패 :rotating_light: (${{ job.status }})",
95+
"emoji": true
96+
}
97+
},
98+
{
99+
"type": "section",
100+
"text": {"type": "mrkdwn", "text": "GitHub Action 바로가기"},
101+
"accessory": {
102+
"type": "button",
103+
"text": {"type": "plain_text", "text": "${{ github.run_id }}"},
104+
"value": "github_action",
105+
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
106+
"action_id": "button-action"
107+
}
108+
}
109+
]
110+
}
111+
env:
112+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
113+
114+
# Notify to Slack (Failure)
115+
- name: Notify deployment to Slack
116+
uses: slackapi/[email protected]
117+
with:
118+
channel-id: ${{ vars.SLACK_DEPLOYMENT_ALERT_CHANNEL }}
119+
payload: |
120+
{
121+
"blocks": [
122+
{
123+
"type": "header",
124+
"text": {
125+
"type": "plain_text",
126+
"text": "${{ steps.info.outputs.repository_name }} 버전 배포 성공 :tada:",
127+
"emoji": true
128+
}
129+
},
130+
{
131+
"type": "section",
132+
"text": {"type": "mrkdwn", "text": "GitHub Action 바로가기"},
133+
"accessory": {
134+
"type": "button",
135+
"text": {"type": "plain_text", "text": "${{ github.run_id }}"},
136+
"value": "github_action",
137+
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
138+
"action_id": "button-action"
139+
}
140+
}
141+
]
142+
}
143+
env:
144+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 commit comments

Comments
 (0)