Skip to content

Github Action that post slack messages when an event occurs.

Notifications You must be signed in to change notification settings

facureyes/slack-notifier

Repository files navigation

Slack Notifier

Lightweight github action for posting to slack (using node-slack-sdk).

Slack Notifier allows you interact with slack while exposing Github's payload. Pairing with a slack bot, this action is able to post a message when a specific event occurs. This is still in develop phase. New events will be added.

Usage

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

  1. Create a .github/workflows/slack-notifier.yml file in your GitHub repo.
  2. Add the following code to the slack-notifier.yml file.
name: Slack Notifier
on: 
  pull_request:
    types: [opened, reopened]
jobs:
  send-notification:
    runs-on: ubuntu-latest
    steps:
      - name: Posting to slack
        uses: facureyes/slack-notifier@v1.0
        with:
          slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
          channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
          event: new_pull_request
          jira-base-url: https://example.atlassian.net/
          jira-project-acronym: EXPL
  1. Create SLACK_BOT_TOKEN and SLACK_CHANNEL_ID secret using GitHub Action's Secret. You will need to generate a Slack bot token from here and assign it the appropriate authorization(see Setting up Actions) and locate the channel ID.

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
event new_pull_request The event define message template to be used. Currently support new_pull_request.
jira-base-url - Jira's base url of your organisation.
jira-project - Jira's project acronym.
slack-bot-token - Slack bot authentication token
channel-id - Slack channel to post to, to get the channel id follow this guide

Building / Deploying / Publishing

Steps to build a new version

ncc build index.js
git add action.yml index.js dist/index.js node_modules/* 
git commit -m "<commit message>"
git tag -a -m "<tag message>" <tag name>
git push --follow-tags

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Links

Licensing

The code in this project is licensed under MIT license.

About

Github Action that post slack messages when an event occurs.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published