forked from dfinity/ic
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (45 loc) · 1.82 KB
/
slack-workflow-run.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
name: Slack Workflow Run
on:
workflow_run:
types:
- completed
branches:
- master
- rc--*
workflows:
- Schedule Daily
- Schedule Weekly
- Release Testing
- Container IC Base Images
jobs:
slack-workflow-run:
name: Send Notification
runs-on: ubuntu-latest
steps:
- name: Setup Message and Channels
id: setup
shell: bash
run: |
# TODO: change to 'eng-idx-alerts,release-management-alerts'
CHANNEL="eng-idx-alerts"
echo "channel=${CHANNEL}" >> $GITHUB_OUTPUT
TRIGGERING_WORKFLOW_NAME="${{ github.event.workflow_run.name }}"
FULL_MESSAGE="nothing"
if [[ "${{ github.event.workflow_run.conclusion }}" =~ ^(success)$ ]]; then
if [[ "$TRIGGERING_WORKFLOW_NAME" == "Release Testing" ]]; then
FULL_MESSAGE=":white_check_mark: ${MESSAGE} :relaxed:"
fi
elif [[ "${{ github.event.workflow_run.conclusion }}" =~ ^(failure|timed_out)$ ]]; then
FULL_MESSAGE=":fire: ${MESSAGE} :disappointed:"
fi
echo "message=${FULL_MESSAGE}" >> $GITHUB_OUTPUT
env:
MESSAGE: "*${{github.event.workflow_run.name}}* ${{github.event.workflow_run.conclusion}} on ${{github.event.workflow_run.head_branch}} - <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|Run#${{github.event.workflow_run.id}}>"
- name: Post Slack Notification
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
if: ${{ steps.setup.outputs.message != 'nothing' }}
with:
channel-id: ${{ steps.setup.outputs.channel }}
slack-message: "${{ steps.setup.outputs.message }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }}