-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yaml
66 lines (66 loc) · 2.67 KB
/
action.yaml
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: Slack Templates
author: Kurt von Laven
description: Send Informative, Concise Slack Notifications With Minimal Effort
inputs:
bot-token:
description: >
The Slack API bot token for your custom app with chat:write scope.
required: true
channel-id:
description: >
The ID of a Slack channel to send notifications to. Your bot should be a
member. Secondary-click on the channel in Slack, and select "Copy link" to
copy a URL containing the channel ID.
required: true
template:
description: >
The type of Slack notification to send: "assignee," "custom," "reviewers,"
or "result." Defaults to "custom." Must pass message if using "custom."
required: false
default: custom
results:
description: >
The job results to report via Slack when using the "result" template.
Defaults to the status of the current job. To report the result of an
entire workflow, use this action from a final notify job that depends on
(a.k.a., "needs") all other jobs. Then, pass join(needs.*.result, ' ').
The highest ranking result will be reported: 1. failure, 2. cancelled,
3. success, 4. skipped. Alternatively, a custom result may be passed
provided that it is quoted for use as a Bash command line argument.
required: false
default: ${{ job.status }}
message:
description: A custom Slack message to send. Do not also pass a template.
required: false
default: Pass message or template to slack-templates.
branding:
icon: hash
color: gray-dark
runs:
using: composite
steps:
- name: Set up Python at the version specified in pyproject.toml.
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version-file: "${{ github.action_path }}/pyproject.toml"
- name: Configure Slack notification.
run: >
python set_slack_message.py
'${{ inputs.template }}'
'${{ inputs.results }}'
'${{ inputs.message }}'
'${{ github.token }}'
'${{ github.event.pull_request.user.login }}'
'*${{ join(github.event.pull_request.requested_reviewers.*.login, '*, *') }}*'
'${{ github.event.pull_request.assignee.login }}'
'${{ github.event.pull_request.number }}'
shell: bash
working-directory: "${{ github.action_path }}"
- name: Send Slack notification.
if: inputs.bot-token != '' && inputs.channel-id != ''
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
channel-id: ${{ inputs.channel-id }}
slack-message: ${{ env.SLACK_MESSAGE }}
env:
SLACK_BOT_TOKEN: ${{ inputs.bot-token }}