doing github-actions local-first!

Hey there! Let’s talk about something that’s been a game changer for me: act. It basically lets you run your GitHub Actions on your machine without a whole lot of configuration—none for me!

So if you’re too excited to check this out on your own, check…


This content originally appeared on DEV Community and was authored by Khushal Bhardwaj

Hey there! Let’s talk about something that’s been a game changer for me: act. It basically lets you run your GitHub Actions on your machine without a whole lot of configuration—none for me!

So if you're too excited to check this out on your own, check out act here.

OR if you want a personalized tutorial on how I went about it, there you go...

I wanted this for a loooong time. If you’re like me, you’ve probably spent way too much time pushing commits with names like “testing action 1” to “testing action 1001” because I can't get these configs right the first time. 😭 It’s a drag, right?

Why Use act?

act lets you run your GitHub Actions locally using Docker. This means you can test your workflows without waiting for them to run on GitHub. It’s a huge time-saver and a life-saver if you're writing complex workflows!

Getting Started

  • Install it however you like; follow the instructions here. I installed it using GitHub CLI (don't hate me for using it).
gh extension install https://github.com/nektos/gh-act
  • Create your workflow in the .github/workflows directory, however you want it.

  • Run act to execute every action, or you can do something specific like act push to run all the actions triggered by a push. You can do a lot more.

  • If you installed it using GitHub CLI like me, just do gh act ....

NOW HERE'S a problem I faced on my machine: if you don't get this, you're done!

If Docker on your machine needs sudo access (like mine does), you might hit a snag. When you try to run gh act, it won’t have access to Docker. So, what do you do?

The Simple Hack

Here’s a quick fix: use sudo -E to run commands while keeping your user context. This way, you can run gh act with Docker access without any hassle.

  • Run Your Workflow: Use this command:
   sudo -E gh act push

The first run might take a bit since it downloads everything (images), but after that, it’s smooth sailing. No more endless commits just to test your actions!

So there you have it! With act, you can save time and avoid the hassle of pushing multiple commits just to test your actions. If you want to learn more, check out the official documentation for act here.


This content originally appeared on DEV Community and was authored by Khushal Bhardwaj


Print Share Comment Cite Upload Translate Updates
APA

Khushal Bhardwaj | Sciencx (2025-01-11T15:28:42+00:00) doing github-actions local-first!. Retrieved from https://www.scien.cx/2025/01/11/doing-github-actions-local-first/

MLA
" » doing github-actions local-first!." Khushal Bhardwaj | Sciencx - Saturday January 11, 2025, https://www.scien.cx/2025/01/11/doing-github-actions-local-first/
HARVARD
Khushal Bhardwaj | Sciencx Saturday January 11, 2025 » doing github-actions local-first!., viewed ,<https://www.scien.cx/2025/01/11/doing-github-actions-local-first/>
VANCOUVER
Khushal Bhardwaj | Sciencx - » doing github-actions local-first!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/11/doing-github-actions-local-first/
CHICAGO
" » doing github-actions local-first!." Khushal Bhardwaj | Sciencx - Accessed . https://www.scien.cx/2025/01/11/doing-github-actions-local-first/
IEEE
" » doing github-actions local-first!." Khushal Bhardwaj | Sciencx [Online]. Available: https://www.scien.cx/2025/01/11/doing-github-actions-local-first/. [Accessed: ]
rf:citation
» doing github-actions local-first! | Khushal Bhardwaj | Sciencx | https://www.scien.cx/2025/01/11/doing-github-actions-local-first/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.