|
| 1 | +--- |
| 2 | +title: "GitHub Actions: A Maintainer's Best Friend" |
| 3 | +tags: ["githubactions", "automation", "opensource", "productivity"] |
| 4 | +authors: nickytonline |
| 5 | +slug: github-actions-a-maintainers-best-friend |
| 6 | +description: "As developers, it’s in our best interest to automate things. The less we have to do in a manual way,..." |
| 7 | +--- |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +If you host your code on GitHub, besides scripts to automate certain actions, you can also leverage the huge ecosystem of [GitHub |
| 12 | +Actions](https://github.com/features/actions). |
| 13 | + |
| 14 | +## Practical Examples |
| 15 | + |
| 16 | +Let’s look at some practical examples of GitHub actions helping maintainers. |
| 17 | + |
| 18 | +### peter-evans/create-or-update-comment |
| 19 | + |
| 20 | +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. |
| 21 | + |
| 22 | +A great GitHub action for this is Peter Evans’ [Create or Update Comment](https://github.com/peter-evans/create-or-update-comment) action. |
| 23 | + |
| 24 | +It’s used in the app repository for OpenSauced. Here’s [how we have it configured](https://github.com/open-sauced/app/blob/beta/.github/workflows/issue.yml). |
| 25 | + |
| 26 | +When a new issue is opened, an issue responds with the following: |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +### bdougie/take-action |
| 31 | + |
| 32 | +My coworker bdougie (@bdougieyo) created the [take Github action](https://github.com/bdougie/take-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. |
| 33 | + |
| 34 | +[](https://github.com/open-sauced/app/issues/2017#issuecomment-1785492904) |
| 35 | + |
| 36 | +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. |
| 37 | + |
| 38 | +[](https://github.com/open-sauced/app/issues/1952#issuecomment-1772176129) |
| 39 | + |
| 40 | +### balazsorban44/nissuer |
| 41 | + |
| 42 | +Another action that came onto my radar a couple of days ago was thanks to [styfle](https://twitter.com/styfle). Although I haven’t used it yet, [nissuer](https://github.com/balazsorban44/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. |
| 43 | + |
| 44 | +I love this note they added in the README. |
| 45 | + |
| 46 | +> 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. |
| 47 | +
|
| 48 | +### Bespoke Actions |
| 49 | + |
| 50 | +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](https://github.com/nickytonline/www.nickyt.co/blob/main/.github/workflows/get-latest-videos.yml) to my blog. |
| 51 | + |
| 52 | +I'm using some GitHub Actions, a custom script that leverages the [GitHub CLI](https://cli.github.com/) and magic. |
| 53 | + |
| 54 | +```yaml |
| 55 | +{% raw %} |
| 56 | +name: Get latest videos |
| 57 | +on: |
| 58 | + schedule: |
| 59 | + # Everyday at midnight UTC |
| 60 | + - cron: '0 0 * * *' |
| 61 | + workflow_dispatch: |
| 62 | + |
| 63 | +jobs: |
| 64 | + update_profile_data: |
| 65 | + name: Get latest videos |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v2 |
| 69 | + - uses: actions/setup-node@v3 |
| 70 | + with: |
| 71 | + node-version: 18 |
| 72 | + - name: Get latest videos |
| 73 | + run: | |
| 74 | + npm install |
| 75 | + node bin/udpdateStreamingPage.js |
| 76 | + - name: Setup git config |
| 77 | + run: | |
| 78 | + git config user.name 'token-generator-app[bot]' |
| 79 | + git config user.email '82042599+token-generator-app[bot]@users.noreply.github.com' |
| 80 | + - name: PR for Videos |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + run: | |
| 84 | + ./bin/pr-videos.sh |
| 85 | +{% endraw %} |
| 86 | +``` |
| 87 | + |
| 88 | +You can see the results on the [streaming page of my site](https://www.nickyt.co/pages/streaming/). |
| 89 | + |
| 90 | +The post is a bit out of date, but I discuss more in depth the automations for my website in |
| 91 | + |
| 92 | +<a href="https://dev.to/nickytonline/my-eleventy-meetup-talk-3b2p">https://dev.to/nickytonline/my-eleventy-meetup-talk-3b2p</a> |
| 93 | + |
| 94 | +## Conclusion |
| 95 | + |
| 96 | +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. |
| 97 | + |
| 98 | +What are some GitHub actions that you’ve leveraged in your projects? Share them in the comments. |
| 99 | + |
| 100 | +Stay saucy peeps! |
| 101 | + |
| 102 | +If you would like to know more about my work in open source, [follow me on OpenSauced](https://oss.fyi/nickytonline). |
0 commit comments