Skip to content

hookerz/action-slack-notify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This action is a part of GitHub Actions Library created by rtCamp.

Slack Notify - GitHub Action

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

A GitHub Action to send a message to a Slack channel.

Screenshot

action-slack-notify-rtcamp

Usage

You can use this action after any other action. Here is an example setup of this action:

  1. Create a .github/workflows/slack-notify.yml file in your GitHub repo.
  2. 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: hookerz/action-slack-notify@v3
      env:
        SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
  1. Create SLACK_WEBHOOK secret using GitHub Action's Secret. You can generate a Slack incoming webhook token from here.

Environment Variables

By default, action is designed to run with minimal configuration but you can alter Slack notification using following environment variables:

Variable Default Purpose
SLACK_CHANNEL Set during Slack webhook creation Specify Slack channel in which message needs to be sent
SLACK_FOOTER - Optional footer text for more contextual info.
SLACK_MESSAGE Generated from git commit message. The main Slack message.

You can see the action block with all variables as below:

    - name: Slack Notification
      uses: hookerz/action-slack-notify@v3
      env:
        SLACK_CHANNEL: general
        SLACK_FOOTER: '<https://example.com|Example>'
        SLACK_MESSAGE: 'Post Content :rocket:'
        SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

Hashicorp Vault (Optional)

This GitHub action supports Hashicorp Vault.

To enable Hashicorp Vault support, please define following GitHub secrets:

Variable Purpose Example Vaule
VAULT_ADDR Vault server address https://example.com:8200
VAULT_TOKEN Vault token s.gIX5MKov9TUp7iiIqhrP1HgN

You will need to change secrets line in slack-notify.yml file to look like below.

on: push
name: Slack Notification Demo
jobs:
  slackNotification:
    name: Slack Notification
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Slack Notification
      uses: hookerz/action-slack-notify@v3
      env:
        VAULT_ADDR: ${{ secrets.VAULT_ADDR }}
        VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}

GitHub action uses VAULT_TOKEN to connect to VAULT_ADDR to retrieve slack webhook from Vault.

In the Vault, the Slack webhook should be setup as field webhook on path secret/slack.

License

MIT © 2019 rtCamp

Does this interest you?

Join us at rtCamp, we specialize in providing high performance enterprise WordPress solutions

About

GitHub Action for sending a notification to a Slack channel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 38.6%
  • Go 36.2%
  • Dockerfile 25.2%