This action sends a notification of the current status of the job. The possible values for the status are: success, failure, or cancelled.
First steps, you need to set GitHub secrets for SLACK_WEBHOOK_URL that is Incoming Webhook URL. You can customize the following parameters:
With Parameter | Required/Optional | Description |
---|---|---|
slack_webhook_url |
Required | The Slack Incoming Webhooks URL. Please specify the environment secret for SLACK_WEBHOOK_URL |
status |
Optional | The result of GitHub Actions job This parameter value must contain the following word: - success - failure - cancelled default is using ${{ job.status }} |
slack_channel |
Optional | Override the default incoming Webhook Slack settings |
slack_username |
Optional | Override the default incoming Webhook Slack settings |
usage with the default incoming Webhook Slack settings,
Create the file workflow.yml
in .github/workflows
folder.
name: The name of your workflow
on [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: craftech-io/slack-action@v1
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
You can override the default incoming Webhook Slack settings for the channel and username, also only send notification to slack if the job failure, e.g:
Possible values are success, failure, or cancelled.
name: The name of your workflow
on [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: craftech-io/slack-action@v1
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
slack_channel: general
slack_username: Github
status: failure
if: failure()
Locate the Slack conversation the message was sent to and it should be waiting for you, like this:
Amazing work - you've now implemented notifactions the your workflows!