-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
54 lines (52 loc) · 2 KB
/
action.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
name: 'Slack Notify'
description: 'slack notify'
inputs:
channel-id:
description: 'slack channel id'
required: true
default: ''
color:
description: 'color'
required: true
default: '#CB2431'
slack_bot_token:
description: 'slack bot secret'
required: true
default: ''
notify_user:
description: 'user to notify'
required: true
default: ''
runs:
using: "composite"
steps:
- name: set notify user
shell: bash
run: |
github_id=${{ github.event.pull_request.user.login || github.event.sender.login || github.actor }}
echo github_id, $github_id
declare -A users=( ["zhoucheng361"]="U035KAH1UV6" ["sanwan"]="U035KAH1UV6" ["davies"]="U5RCBSN2C" ["SandyXSD"]="U01UPCZMK99" ["tangyoupeng"]="UK04TUV0C" ["zhijian-pro"]="U02J2DL3CUA")
slack_id="${users["$github_id"]}"
echo slack_id: $slack_id
echo "slack_id=$slack_id" >> $GITHUB_ENV
- name: send slack notification
if: ${{github.event_name != 'workflow_dispatch'}}
uses: slackapi/[email protected]
with:
channel-id: "${{inputs.channel-id}}"
payload: |
{"attachments": [
{
"pretext":"<@${{env.slack_id}}> CI check ${{ job.status }} on ${{ github.event_name }}",
"mrkdwn_in":["text"],
"author_name":"${{ github.event.pull_request.user.login || github.event.sender.login || github.actor }}",
"author_link":"${{ github.event.pull_request.user.html_url || github.event.sender.html_url}}",
"author_icon":"${{ github.event.pull_request.user.avatar_url || github.event.sender.avatar_url }}",
"title":"${{ github.event.pull_request.title || github.event.head_commit.message }}",
"text":"https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
"color":"${{inputs.color}}"
}
]
}
env:
SLACK_BOT_TOKEN: ${{inputs.slack_bot_token}}