Notify Slack of your github notifications, which can be scheduled to run using Github Actions.
Slack
You can register a white list and black list of repositories to be notified.
- Need to create a slack bot. Access Slack Applications.
- [Create new app] -> [From scratch]
- [OAuth & Permissions] -> Add chat:write to Bot Token Scopes and re install.
- Create a github token. Access Personal access tokens, Tokens require the score of repo, notifications.
- 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 }}
- Register environment variables in the Actions secrets.
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) |