Skip to content

Commit b2dd287

Browse files
authored
Merge pull request #2 from code4fukui/feature/add-slack-alert
👍githubActionsが実行失敗した時にエラーメッセージを送信できるように変更しました
2 parents d916b18 + ff4748a commit b2dd287

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/update.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,30 @@ jobs:
2525
git add .
2626
git commit -m 'update data' && git push ${REPO} HEAD:${{github.event.pull_request.head.ref}} || true
2727
git push
28+
- name: Notify Slack on failure
29+
if: failure()
30+
run: |
31+
curl --fail -X POST -H 'Content-type: application/json' \
32+
--data '{
33+
"attachments": [
34+
{
35+
"color": "#E01E5A",
36+
"title": "【観光来訪者数ダッシュボード】データ更新に失敗しました。",
37+
"title_link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
38+
"fields": [
39+
{
40+
"title": "ワークフロー",
41+
"value": "${{ github.workflow }}",
42+
"short": true
43+
},
44+
{
45+
"title": "ジョブ",
46+
"value": "${{ github.job }}",
47+
"short": true
48+
}
49+
],
50+
"text": "GitHub Actionsの実行中にエラーが発生しました。至急ログを確認してください。"
51+
}
52+
]
53+
}' \
54+
${{ secrets.SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)