diff --git a/notify-slack/action.yml b/notify-slack/action.yml deleted file mode 100644 index c896c47..0000000 --- a/notify-slack/action.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: 'Slack Notification' -description: 'Send notifications to Slack' -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 - title: - description: 'Message title' - required: true - text: - description: 'Message text' - required: true - color: - description: 'Color of the message' - required: false - default: 'good' - -runs: - using: composite - steps: - - name: Notify Slack Channel - shell: bash - run: | - curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" \ - --data '{ - "username": "${{ inputs.slack-username }}", - "channel": "${{ inputs.slack-channel }}", - "attachments": [ - { - "title": "${{ inputs.title }}", - "text": "${{ inputs.text }}", - "color": "${{ inputs.color }}" - } - ] - }' diff --git a/notify-slack/workflow-status/action.yml b/notify-slack/workflow-status/action.yml new file mode 100644 index 0000000..df6fa3c --- /dev/null +++ b/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": "** **", + "color": "'$color'" + } + ] + }'