The Best GitHub Actions You Should Use

The Best GitHub Actions You Should Use

Julien Danjou

GitHub Actions are a collection of tools that help you streamline your development workflows through automation. These actions are event-driven, meaning they’ll trigger upon certain things happening.

There are tons of GitHub Actions you can use—here are some of the best.

1. Checkout

Everybody knows about Checkout. It's the first action running in many workflows as it download your Git repository locally.

In general, you don't do much with this action because it checks out your target repository to run actions on top of it. That's all.

What you might not know is that it has plenty of options. For example, it has a fetch-depth option that allows you to clone not only the tip of the branch but its full history – handy to do some deeper Git tree analysis.

Its documentation has a long list of scenarios and explains how to implement them.

2. Close Stale Issues

As humans, it’s easy to leave issues and pull requests untouched long after we forget about them. The Close Stale Issues action fixes that.

Close Stale Issues places labels on inactive pull requests and issues after a defined period of inactivity along with a comment about it. If anyone comments or does anything to the item in question, the label is removed.

Otherwise, Close Stale Issues closes the pull request or issue and notifies everyone with a comment.

3. Cache

The Cache action improves workflow execution times by allowing build outputs and caching dependencies. In essence, the cache feature stops GitHub from having to download dependencies you frequently use, saving money while shortening runtime and cutting network utilization.

4. Create Release

Ready to release your project for others to try out and use? The Create Release action will come in handy here, as that’s exactly what it lets you do.

On top of that, Create Release enables you to upload an artifact to the release if you choose to, but you’re not required to.

5. Setup

There's a long list of actions named Setup. These all allow you to set up your GitHub workflows with specific versions of your favorite programming languages.

For example, setup-python allows you to set up multiple Python versions, even using PyPy or different architectures.

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-python@v2
    with:
      python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
  - run: python my_script.py

There are numerous other Setup actions that you can find here.

6. Create Issue From File

The Create Issue From File action lets you create an issue based on a file output by a previous action. It’s designed to complement other actions that might output to a file.

This action can come in handy when automating issue creation, based, for example, on a regular run of your test and detect flaky tests:

  1. Run your test once a day via a GitHub action
  2. Create an issue file for every test that fails
  3. Open a bunch of new issues

7. Script

With the Script action, it’s simple and quick to write a script in your workflow that uses the GitHub API and the workflow run.

According to GitHub’s documentation, this action is still more of an experiment. They say that the API may change in future versions.

8. Copybara

Source code sometimes needs to exist in several repositories at once. For example, your project may have both a public repository and a confidential repository, and both need that source code.

Copybara is a tool created and used internally by Google to transform and move code between repositories for instances like these.

Copybara lets you contribute code to any repository, but you must designate one as the authoritative repository. It’s most often used for repeated movements of code between repositories but may be used for a one-off code move as well.

9. Discord & Slack

Both Slack and Discord are good tools for people working on open-source projects to communicate with each other. Thanks to some GitHub actions, you can integrate these into your workflows.

That way, you can do things such as notify project participants of new commits seamlessly inside whichever app you use to keep in touch with those participants.

10. Mirror Action

Do you have several copies of the same fill in your repository? You’ll want to make sure they’re always synced up. The Mirror Action does just that, checking to see if the content of two separate files is the same or not.

All these GitHub actions automate small parts of your workflow to boost your efficiency.

Know what else goes well with these excellent GitHub actions? A merge bot like Mergify—because it automates so much more. With Mergify, you’ll hardly ever have to manually approve pull requests or assign code reviewers.

Mergify is free to use with GitHub and takes maybe two clicks to install. Get Mergify today!