-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (62 loc) · 1.93 KB
/
notify_slack_on_ci_failed.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ## Summary
#
# "SLACK_XXX_WEBHOOK_URL" に紐づく channel に、CI 失敗時用の Slack 通知をする。
# ## Usage
#
# name: Notify to Slack on CI failure
#
# jobs:
# notify:
# uses: route06/actions/.github/workflows/notify_slack_on_ci_failed.yml@v2
# with:
# title: CI failed / ci.yml
# secrets:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_XXX_WEBHOOK_URL }} # Set this secret
name: Notify to Slack on CI failure
on:
workflow_call:
inputs:
title:
description: Slackメッセージのタイトル
required: true
type: string
secrets:
SLACK_WEBHOOK_URL:
required: true
jobs:
notify-slack-on-ci-failed:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set COMMIT_MESSAGE
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" | tr '\n' ' ' >> "$GITHUB_ENV"
- name: Notify to slack
uses: tokorom/action-slack-incoming-webhook@d57bf1eb618f3dae9509afefa70d5774ad3d42bf # v1.3.0
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
text: ${{ inputs.title }}
attachments: |
[
{
"color": "bad",
"author_name": "${{ github.actor }}",
"author_icon": "${{ github.event.sender.avatar_url }}",
"fields": [
{
"title": "Commit Message",
"value": "${{ env.COMMIT_MESSAGE }}"
},
{
"title": "GitHub Actions URL",
"value": "${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}"
},
{
"title": "Compare URL",
"value": "${{ github.event.compare }}"
}
]
}
]