DEV Community

Play Button Pause Button
Brian Douglas for GitHub

Posted on • Updated on

Run your GitHub Actions like a makefile

When developing GitHub Action workflows, you might find yourself pushing arbitrary commits to trigger the logs.

Don't do that!

Instead, use the tools available to you to debug locally, like act.

GitHub logo nektos / act

Run your GitHub Actions locally 🚀

act-logo

Overview push Join the chat at https://gitter.im/nektos/act Go Report Card awesome-runners

"Think globally, act locally"

Run your GitHub Actions locally! Why would you want to do this? Two reasons:

  • Fast Feedback - Rather than having to commit/push every time you want to test out the changes you are making to your .github/workflows/ files (or for any changes to embedded GitHub actions), you can use act to run the actions locally. The environment variables and filesystem are all configured to match what GitHub provides.
  • Local Task Runner - I love make. However, I also hate repeating myself. With act, you can use the GitHub Actions defined in your .github/workflows/ to replace your Makefile!

How Does It Work?

When you run act it reads in your GitHub Actions from .github/workflows/ and determines the set of actions that need to be run. It uses the Docker API to either pull or build the necessary images, as defined in your workflow…

When you run act it reads in your GitHub Actions from .github/workflows/ and determines the set of actions that need to be run. It uses the Docker API to either pull or build the necessary images, as defined in your workflow files and finally determine the execution path based on the defined dependencies. Once it has the execution path, it then uses the Docker API to run containers for each action based on the images prepared previously. The environment variables and filesystem are all configured to match what GitHub provides.

Check out the creator's GitHub Actions Hero story.

This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev.

Top comments (3)

Collapse
 
skullface profile image
skullface

omg this is timely and helpful as hell, I just did that and rebased to remove my random commits EARLIER TODAY. thanks @bdougie!!!

Collapse
 
bdougieyo profile image
Brian Douglas

I am glad I can be helpful!

Collapse
 
kreutzenia profile image
kreutzenia

Super