-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 1.87 KB
/
Copy pathsendslackmsgtopusher.yml
File metadata and controls
66 lines (57 loc) · 1.87 KB
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
name: Send Slack message to pusher
on:
workflow_call:
inputs:
emailslackuser:
required: true
type: string
shortmsg:
required: true
type: string
blocks:
required: true
type: string
jobs:
send_slack_msg:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: logging
run: |
echo "emailslackuser: ${{ inputs.emailslackuser }}"
- name: Find correspondences
id: email
uses: slackapi/slack-github-action@v2.1.1
with:
method: users.lookupByEmail # https://api.slack.com/methods/users.lookupByEmail
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
email: ${{ inputs.emailslackuser }}
- name: Search email detail
if: ${{ steps.email.outputs.ok }}
run: |
SLACK_USER_ID=$(echo '${{ steps.email.outputs.response }}' | jq -r '.user.id')
echo "SLACK_USER_ID=$SLACK_USER_ID" >> $GITHUB_ENV
- name: Send a direct message
if: ${{ steps.email.outputs.ok }}
uses: slackapi/slack-github-action@v2.1.1
with:
errors: true
method: chat.postMessage # https://api.slack.com/methods/chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
"channel": "${{ env.SLACK_USER_ID }}",
"text": "${{ inputs.shortmsg }}",
"blocks": ${{ inputs.blocks }}
- name: Fallback
id: fallback_slack
if: failure()
uses: slackapi/slack-github-action@v2.1.1
with:
errors: true
method: chat.postMessage # https://api.slack.com/methods/chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
"channel": "ci",
"text": "${{ inputs.shortmsg }}",
"blocks": ${{ inputs.blocks }}