DEV Community

Cover image for How to test your GitHub Actions locally
Rajvir Singh for ByteSlash

Posted on • Updated on

How to test your GitHub Actions locally

So Dev & GitHub Team just announced the Github Action Hackathon. I am also participating in it. But I ran into a troublesome problem, and I think some of you guys are too. That is we always have to push the files to the remote repo in order to test the action, But it is a kinda pain to do it every time you make a change. I finally have found a solution to this problem.

Act the solution

"Think globally, act locally"

The two important reasons that you should use Act:

  • 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!

I copied them from Act's readme, Because I am lazy

Act is pretty reliable for testing actions, And I can go into details but I would be just repeating the stuff that is already on Act's Readme. So if you want deeper dive then you can check Act's Repo.

I hope you guys can figure everything else yourselves, as I am also busy making my project for this hackathon. But I felt an urge to tell others about this amazing tool.

Have a good day, Best of luck!
Rajvir Singh

Discussion (3)

deninpaulv profile image
Denin Paul

Awesome article! I always wondered if there was a better way. Not anymore!

rajvirsingh1313 profile image
Rajvir Singh Author

Thanks Denin, Yeah I too wondered around, as pushing everytime you added a space is annoying and makes commit meaningless. But I now found the solution now I finally can complete my project

rajvirsingh1313 profile image
Rajvir Singh Author

I hope everyone is enjoying this hackathon, If you guys have any other tools that mighty be helpful for others then please share them in comments.

Have a good day