Notify Bot : Github Action + Workflow

Motivation for Building building this Github Action :

If you are an Open Source Maintainer or Contributor or a developer working with a team that has a huge number of members then you have definitely used Slack at one point. And as a developer we even used Github. Since I m an Open Source Contributor and Maintainer many times I have to find issues and take help regarding those from community members to solve that issue or direct the beginner contributor to the proper issue. And mostly I have communicated and collaborated with other maintainers and contributors on Slack so I thought building this action which will surely save the time of Maintainers and contributors.

Features:

  1. Greet - When the contributor of the project creates a pull request a "Thank you" greeting is sent.
  2. Issue Notification - When someone creates a new issue few contexts like issue title, issue creator/contributor username, and link to the GitHub issue are shared on the Slack channel.
  3. Issue Notification - When someone creates a pull request few contexts like issue title, pull request creator/contributor username, and link to the Github issue are shared on the Slack channel.

What will this Github action do? If I use it in my Github project!!

  • If you are a maintainer of the project this GitHub action will surely save your time. And let's help newbie contributors effectively and discuss the following issue on slack. You can direct new contributors to the good first issue and direct them properly.

How to get and configure Tokens :

To use this action + workflow we need 3 Tokens/API keys/Security keys: They are as following:

  1. Github Token : You don't need to worry about this token since it will be automatically configured by Github.
  2. Tenor gif Token:
  3. Go ahead and visit the tenor gif developer portal and sign up with Gmail and get your free API key.
  4. After getting your Tenor Token you can go to your Github repository where you want to set up this action then go to the settings of that repository.
  5. Search for the 'secrets' option. And then click on new repository secrets.
  6. Give it a name and paste the token(eg. name: TENOR_TOKEN value: copied token from tenor gif portal).
  7. Slack App Token:
  8. Go to Slack App portal and click on 'Create an App' Image description

  9. After clicking on 'create an app' you will be asked whether you want to start from scratch or from app manifest we will go for the 'from the scratch option' Image description

  10. Then one popup will arise asking for the app name and to use it in which slack workspace. Image description

  11. Now search for Review scopes something like this option. Click on that button. Image description

  12. And add 2 scopes. As shown in the figure below. Image description

  13. You will see OAuth and Permissions option in the left sidebar. Go to that option and scroll a little down and click on 'install to workspace' to the workspace(workspace which we selected at the start)

Image description

  • Allow the App to join the workspace. Image description

  • After this above step you will see your slack app token copy it and store it in repository secrets similar to the tenor token.

Image description

  • Lastly, invite your app into the Slack channel you want. Image description

How to setup this action + workflow on our repository:

  • After configuring the token stuff you are just a few steps away.
  • Create .github/workflows/my_action.yml directory.
  • After that paste this yml code into the my_action.yml file.
name: Notify Bot

on:
  pull_request:
      branches: [ master , main ] 
      types: [opened,closed]
  issues:
      types: [opened]


jobs:
  Greet:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: StarTrooper08/Notify-Bot
        with:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          TENOR_TOKEN: ${{secrets.TENOR_TOKEN}}


  notifyPR:

    runs-on: ubuntu-latest
    steps:
    - name: Notify slack about PR
      env:
        SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
      uses: abinoda/slack-action@master
      with:
        args: '{\"channel\":\"channel_id\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Github Pull Request:* ${{ github.event.pull_request.title }}\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Contributor Github Username:* ${{ github.event.pull_request.user.login }}\n*Request State:* ${{ github.event.pull_request.state }}\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<${{ github.event.pull_request.html_url }}|View Pull Request>\"}}]}'


  notifyissue:

    runs-on: ubuntu-latest

    steps:
    - name: Notify slack about issue
      env:
        SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
      uses: abinoda/slack-action@master
      with:
        args: '{\"channel\":\"channel_id\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Github Issue:* ${{ github.event.issue.title }}\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Contributor Github Username:* ${{ github.event.issue.user.login }}\n*Issue State:* ${{ github.event.issue.state }}\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<${{ github.event.issue.html_url }}|View Issue>\"}}]}'

Note: Wherever I have written channel_id in args of the notify issue and notifyPR jobs in the my_action.yml file put the id of the channel where you have to install your slack app. You will get the channel id in the link of slack workspace https://app.slack.com/client/[workspace ID]/[channel ID]

Congrats You have Successfully added the Github Workflow🎉🚀. Image description Now you can create new pull requests and issues and see the Magic happening ✨!!!

Image description

github.com/StarTrooper08/Notify-Bot