As developers, it’s in our best interest to automate things. The less we have to do in a manual way, the better. As soon as manual intervention is required, there is potential for failure or a mishap. Aside from that, it’s your time as a maintainer that could be spent elsewhere.
If you host your code on GitHub, besides scripts to automate certain actions, you can also leverage the huge ecosystem of GitHub
Actions.
Practical Examples
Let’s look at some practical examples of GitHub actions helping maintainers.
peter-evans/create-or-update-comment
If someone opens an issue on your repository, you could respond with a personal message saying thank you, but those keystrokes are probably better suited for other things. Automate a message reply instead, thanking the community member for creating the issue and mentioning you will look into it. An automated message to the issue opener is friendly, even if it’s automated.
A great GitHub action for this is Peter Evans’ Create or Update Comment action.
It’s used in the app repository for OpenSauced. Here’s how we have it configured.
When a new issue is opened, an issue responds with the following:
bdougie/take-action
My coworker bdougie (@bdougieyo) created the take Github action. It allows external contributors to self-assign issues by typing .take
into a comment of an issue. This removes the burden of a bit of back and forth between contributors and maintainers.
Of course, we don’t want external contributors self-assigning any issue they want. The take action also has the concept of blocking labels. For example, if an issue has a 👀 needs triage
label, we can add this label to a list of blocking labels.
balazsorban44/nissuer
Another action that came onto my radar a couple of days ago was thanks to styfle. Although I haven’t used it yet, nissuer looks like a great utility belt GitHub action for maintainers. The Next.js repository uses it, so I'm sure it brings lots of value to a maintainer.
I love this note they added in the README.
NOTE: Developers are coming to your project with all sorts of backgrounds/skill levels or understanding of the open-source world. Show empathy while using this action. 💚 We recommend adding comments that not only dismiss unhelpful issues/comments, but educate the user on how to be more helpful in the future.
Bespoke Actions
Don’t see a GitHub action for what you need? Create your own. You can even build your own by composing it from existing GitHub actions. Here's an example of a bespoke workflow I use for pulling in my latest video content from YouTube to my blog.
I'm using some GitHub Actions, a custom script that leverages the GitHub CLI and magic.
name: Get latest videos
on:
schedule:
# Everyday at midnight UTC
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
update_profile_data:
name: Get latest videos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Get latest videos
run: |
npm install
node bin/udpdateStreamingPage.js
- name: Setup git config
run: |
git config user.name 'token-generator-app[bot]'
git config user.email '82042599+token-generator-app[bot]@users.noreply.github.com'
- name: PR for Videos
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./bin/pr-videos.sh
You can see the results on the streaming page of my site.
The post is a bit out of date, but I discuss more in depth the automations for my website in
Automate syndication of your content with Eleventy, dev.to, and GitHub Actions
Nick Taylor ・ May 26 '22
Conclusion
These are just examples of tasks you can automate, and if you’re using GitHub, there is a huge ecosystem of GitHub actions to help with your automation goals.
What are some GitHub actions that you’ve leveraged in your projects? Share them in the comments.
Stay saucy peeps!
If you would like to know more about my work in open source, follow me on OpenSauced.
Top comments (6)
GA is really useful, thanks for your post ! 👻
Great write-up! We also have a bunch of articles on Github Actions in our Newsletter, check it out - packagemain.tech/p/github-actions-...
Thanks, Alex, and thanks for sharing your newsletter!
I didn't except such useful posts when I first followed OpenSauced, but your contents are truly awesome! 🙏