using act to run github actions locally
act is a tool that lets you run github actions locally. it’s useful for testing and debugging workflows without pushing to your repo.
problem
testing github actions can be slow and cumbersome. each change requires a commit, push, and wait for the action to run on github’s servers.
solution
act allows you to run actions locally, speeding up the development cycle and reducing the load on github’s servers.
installation and setup
install act on mac using homebrew:
ensure docker is installed and running, as act uses it to simulate the github actions environment.
mac m1 installation
architecture error
to solve just add --container-architecture linux/amd64
to your act command:
docker socket error
figure out which socket is being used by docker:
so we get this error because we are running docker desktop and the socket is located in ~/.docker/run/docker.sock
.
to solve this issue, you need to create a symlink to the docker socket:
.actrc file
you can create a ~/.actrc
file in your project directory to store default options for act:
basic usage
run all actions:
run a specific job:
use a specific event:
common use cases
- testing workflow changes:
- debugging a specific job:
- using custom docker image:
potential pitfalls
- secrets: act doesn’t have access to your github secrets by default. use
-s
flag to pass secrets:
-
resource limitations: some actions might require more resources than your local machine can provide.
-
platform-specific actions: actions designed for specific os or architectures might not work locally.
conclusion
act is a powerful tool for local github actions development. it speeds up testing, simplifies debugging, and reduces dependency on github’s infrastructure. remember to keep your local environment as close to github’s as possible for accurate results.
key takeaways:
- install with homebrew on mac
- use docker to simulate github’s environment
- easily test specific jobs or events
- be mindful of secrets and resource limitations