Skip to content

Commit

Permalink
Specialize Slack Notification into action about workflow statuses (#3)
Browse files Browse the repository at this point in the history
* create Workflow Status Slack Notification

* Correct the branch name, allowing running on all branches

* Create color codes

* Remove double quotes

* Fix formatting
  • Loading branch information
Mondlicht1 committed Mar 12, 2024
1 parent b527e5a commit 74c4d89
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 41 deletions.
41 changes: 0 additions & 41 deletions notify-slack/action.yml

This file was deleted.

40 changes: 40 additions & 0 deletions notify-slack/workflow-status/action.yml
@@ -0,0 +1,40 @@
name: 'Workflow Status Slack Notification'
description: 'Send notifications to Slack about the status of a github workflow'
inputs:
slack-webhook:
description: 'Slack webhook URL'
required: true
slack-username:
description: 'Username to display in the message'
required: true
slack-channel:
description: 'Slack channel to post the message'
required: true
workflow-status:
description: 'The status of the workflow'
required: true

runs:
using: composite
steps:
- name: Notify Slack Channel
shell: bash
run: |
color="warning"
if [ "${{ inputs.workflow-status }}" == "failed" ]; then
color="danger"
elif [ "${{ inputs.workflow-status }}" == "succeeded" ]; then
color="good"
fi
curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" \
--data '{
"username": "${{ inputs.slack-username }}",
"channel": "${{ inputs.slack-channel }}",
"attachments": [
{
"title": "[${{ github.repository }}] ${{ github.workflow }} ${{ inputs.workflow-status }} on ${{ github.head_ref }}",
"text": "*<https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha || github.sha }}|Commit>* *<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow>*",
"color": "'$color'"
}
]
}'

0 comments on commit 74c4d89

Please sign in to comment.