You can use this action after any other action. Here is an example setup of this action:
- Create a
.github/workflows/slack-notify.yml
file in your GitHub repo. - Add the following code to the
slack-notify.yml
file.
on: push
name: Slack Notification Demo
jobs:
slackNotification:
name: Slack Notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Slack Notification
uses: skyfriends/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- Create
SLACK_WEBHOOK
secret using GitHub Action's Secret. You can generate a Slack incoming webhook token from here.
By default, action is designed to run with minimal configuration but you can alter Slack notification using following environment variables:
You can see the action block with all variables as below:
- name: Slack Notification
uses: skyfriends/action-slack-notify@v2
env:
SLACK_CHANNEL: general
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: 'Post Content :rocket:'
SLACK_TITLE: Post Title
SLACK_USERNAME: skyfriends
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}