Notify Bot : Github Action + Workflow
source link: https://dev.to/star_trooper/notify-bot-github-action-workflow-2676
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Notify Bot : Github Action + Workflow
My Workflow
Motivation for Building building this Github Action :
If you are Open Source Maintainer or Contributor or a developer working with team which has huge number of members then you have definitely used Slack at one point. And as a developer we even used Github.
Since I m Open Source Contributor and Maintainer many a times I have to find issues and take help regarding those from community members to solve that issue or direct the beginner contributor to proper issue . And mostly I have communicate and collaborate with other maintainer and contributors on Slack so I thought building this action which will surely save time of Maintainers and contributors .
Features:
- Greet - When contributor of the project creates pull request a "Thank you" greet is send .
- Issue Notification - When someone creates new issue few context like issue title, issue creator/contributor username and link to the github issue is shared on Slack channel.
- Issue Notification - When someone creates pull request few context like issue title, pull request creator/contributor username and link to the github issue is shared on Slack channel.
What will this github action do? If I use it in my github project!!
- If you are maintainer of project this github action will surely save your time . And let help newbie contributors effectively and discuss them about the following issue on slack. You can direct new contributors to the good first issue and direct them properly.
Submission Category:
Maintainer Must-Haves
Yaml File or Link to Code:
StarTrooper08 / Notify-Bot
Maintainer Friendly Github Actions
Notify-Bot
Features :
- Notification: Sends Message on Slack channel when someone create's issue or Pull Request.
- Greeting: Greets to the Contributors when they create new Pull Request
How to get and configure Tokens :
To use this action + workflow we need 3 Tokens/API keys/Security keys:
They are as following:
- Github Token : You don't need worry about this token since it will be automatically configured by Github.
- Tenor gif Token:
- Go ahead and visit the tenor gif developer portal and sign up with gmail and get your free api key.
- After getting your Tenor Token you can go to your github repository where you want to setup this action then go to settings of that repository .
- Search for 'secrets' option. And then click on new repository secrets.
- Give it a name and paste the token(eg.name: TENOR_TOKEN value: copied token from tenor gif portal).
- Slack App Token:
- Go to Slack App portal and click on 'Create an App'
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 'from scratch option'
Then one popup will arise asking for app name and to use it in which slack workspace.
Now search for Review scopes something like this option. Click on that button.
And add 2 scopes. Shown in the figure below.
You will see OAuth and Permissions option in the left side bar. Go to that option and scroll little down and click on 'install to workspace' to the workspace(workspace which we selected at the start)
Allow the App to join the workspace.
After this above step you will see your slack app token copy it and store it in repository secrets similar to tenor token.
- Lastly invite your app into the slack channel you want.
How to setup this action + workflow on our repository:
- After the configuring the token stuff you are just few steps away.
- Create
.github/workflows/my_action.yml
directory. - After that paste this yml code into
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>\"}}]}'
Enter fullscreen mode
Exit fullscreen mode
Note: Wherever I have written
channel_id
inargs
of thenotifyissue
andnotifyPR
jobs in my_action.yml file put the id of the channel where you have install your slack app. You will get the channel id in the link of slack workspacehttps://app.slack.com/client/[workspace ID]/[channel ID]
Congrats You have Successfully added the Github Workflow🎉🚀.
Now you can create new pull request and issue and see the Magic happening ✨!!!
Recommend
-
79
-
25
HN Notify.xyz Subscribe to your Hacker News Feed Aren't you tired of never knowing when someone responded to your witty retort? If you are like me, you will get com...
-
6
Adding approval workflow to your GitHub ActionThis website uses cookies to ensure you get the best experience on our website. Learn more
-
4
Erika Heidi Posted on Nov 16...
-
6
Unable to start the hive action from the second run of Oozie Workflow Job advertisements Am facing bit issue while running Hive Action from Oo...
-
2
My Workflow Automation everywhere is the pinnacle of DevOps and version control can be part of that too however if you enable branch protection rules it can make it impossible to automatical...
-
7
Blog Post Workflow GitHub Action My Workflow Show your latest blog posts from any sources or StackOverflow activity or Youtube Videos on your GitHub profile/project readme automatically using the RSS feed. With an ama...
-
1
The GitHub Actions Hackathon has just concluded. Congrats to everyone who submitted an Action. Throughout the hackathon, we notic...
-
6
Action 基础Github Actions常用Action介绍actions/checkout@v2
-
10
VR gaming doesn’t enjoy much physical merchandise, but this Astro Bot figure is pretty much perfect. The new...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK