Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specialize Slack Notification into action about workflow statuses (#3)
* 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
1 parent
b527e5a
commit 74c4d89
Showing
2 changed files
with
40 additions
and
41 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'" | ||
} | ||
] | ||
}' |