My Workflow
I'd been intrigued by GitHub actions ever since they were announced, but I was never really sure of how they worked or fit into the GitHub Repository ecosystem - and this seemed like a great time to jump in and try them out!
When starting something new, my favorite way to do things is take an existing thing and play with it. I took the basis of action-cats and modified it to respond with a different gif based on the sentiment of the PR description using the npm package sentiment (sentiment analysis was another thing I have been wanting to dabble with for a while now).
So what exactly is happy-PR?
- It takes the description of new pull requests and runs it through sentiment to return a value from -5 to +5, with -5 being extremely aggressive or angry and +5 being extremely positive or happy.
- It responds to the Pull Request with the score and an associated gif (there's one for each integer from -5 to +5 - can you collect them all? π)
You can see an example of the response on this PR
Submission Category: Wacky Wildcards
I don't think this is particularly useful - it's really just a reason to try out GitHub Actions π₯³
Yaml File or Link to Code
The Repo can be found here:
TerabyteTiger / action-happyPR
GitHub Action to check tone of PR
Happy PR β¨
This action uses sentiment to analyze the sentiment of an incoming PR and responds with a gif and score from -5 to 5.
While this could have real-world uses, in it's current state it's very much just for fun π
Inputs
GITHUB_TOKEN
Required This is an auto-generated token that allows Happy PR to respond as the GitHub action bot.
Outputs
An example of a response to a somewhat positive Pull Request response:
Example usage
on:
pull_request:
types: [opened]
uses: TerabyteTiger/action-happyPR@v3
id: happy
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Or if you want to integrate it with your repository, on the marketplace here: https://github.com/marketplace/actions/happy-pr
Additional Resources / Info
Thanks again to action-cats for the great starting point with getting this up an running!
Potential Changes
Random thoughts I had about this action that could be added:
- Initially I wanted to include 10 more gifs for the .5 increments, but that felt like a distraction from getting the action working (and picking half step sentiment gifs is pretty hard as it turns out)
- It could include a "minimum sentiment" option and automatically reject any PR without a minimum rating, although I'm not sure how much this could be impacted by spamming a bunch of "positive" words to average out the score
Top comments (1)
ππ»ππ»
Content Sentiment Analysis: Explore the emotion score of your content with Google API
Bogdan Covrig γ» Aug 22 γ» 4 min read