github-notifications-to-slack

command module
v0.0.0-...-1e61c20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 12 Imported by: 0

README

Github Notifications To Slack

Notify Slack of your github notifications, which can be scheduled to run using Github Actions.

actions

Slack

image

You can register a white list and black list of repositories to be notified.

Usage

  1. Need to create a slack bot. Access Slack Applications.
  2. [Create new app] -> [From scratch]
  3. [OAuth & Permissions] -> Add chat:write to Bot Token Scopes and re install.
  4. Create a github token. Access Personal access tokens, Tokens require the score of repo, notifications.
  5. Create a repository to run scheduled notifications github actions and create the following Actions.

.github/workflows/slack-notify.yml

on:
  schedule:
    - cron: "*/10 * * * *"

jobs:
  notify:
    runs-on: ubuntu-latest
    name: notify
    steps:
      - uses: actions/checkout@v3
      - name: Github Notifications To Slack
        uses: shzxcv/github-notifications-to-slack@v1
        env:
          NOTIFICATION_GITHUB_TOKEN: ${{ secrets.NOTIFICATION_GITHUB_TOKEN }}
          SLACK_BOT_OAUTH_TOKEN: ${{ secrets.SLACK_BOT_OAUTH_TOKEN }}
          SLACK_USER_ID: ${{ secrets.SLACK_USER_ID }}
  1. Register environment variables in the Actions secrets.

Environment Variables

Variable Required Purpose
NOTIFICATION_GITHUB_TOKEN true The token of the github account. repo and notifications scopes are required.
SLACK_BOT_OAUTH_TOKEN true bot token for the slack app to be notified. chat:write is required.
SLACK_CHANNEL false Specify the slack channel to be notified. (#test-channel)

* Either SLACK_CHANNEL or SLACK_USER_ID is required.
SLACK_USER_ID false The user id of the slack user to whom the Direct Message will be sent.(U01ABCD23EF)

* Either SLACK_CHANNEL or SLACK_USER_ID is required.
INCLUDE_GITHUB_REPOS false Repository to be included in the notification. (shzxcv/repo1,shzxcv/repo2)

* If the same repository is registered in INCLUDE_GITHUB_REPOS and EXCLUDE_GITHUB_REPOS, INCLUDE_GITHUB_REPOS has priority.
EXCLUDE_GITHUB_REPOS false Repository to exclude notifications. (shzxcv/repo1,shzxcv/repo2)

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL