Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack notification v2 #3

Merged
merged 5 commits into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'"
}
]
}'