Run GitHub Actions Locally with Act

September 5th, 2023

Run GitHub Actions Locally with Act

You can run GitHub actions locally with a CLI tool called nektos/act which reads your .github workflows and determines the actions that need to run:

Act uses Docker to pull or build the necessary images that are defined in your workflow. It then uses the Docker API to run containers for each action based on the images provided and the environment variables are set up to match GitHub.

This CLI has installation instructions for various package managers and systems. Once you get it installed and configured, here are some commands you can try:

act -l # lists all the actions for all the events
 
act workflow_dispatch -l # list actions for a specific event
 
# Run a specific event
act pull_request
 
# Run a specific job
act -j test
 
# Collect artifacts to a given folder 😱
act --artifact-server-path /tmp/artifacts
 
# Dry run mode
act -n

Learn More

The Act repository has an images doc that lists all Docker images that can be used with act. There's documentation for setup and usage in the User Guide and you can view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.