DEV Community

Denis Kisina
Denis Kisina

Posted on • Originally published at deniskisina.dev on

Test GitHub Action workflows locally

Developing a GitHub Actions workflow is time-consuming. The process involves repeatedly committing and pushing your changes to your workflows to the remote repository to test them.

This increases the time spent working and pollutes the repository with unnecessary commits and logs creating unnecessary clutter in the repository version history.

This increases the time spent working and pollutes the repository with unnecessary commits and logs, creating unnecessary clutter in the repository’s version history.

Fortunately, there are tools to test GitHub Actions workflow locally before pushing the workflows to the repository. One of the more widely used tool is called act that uses Docker containers to run and test your actions locally This tool allows you to run GitHub Actions workflows directly on your local machine, with YAML syntax support.

What is act?

The goal of act is to provide a way to spin up a GitHub Action locally, running it in a Docker container as if it were running in GitHub.

Installing act CLI

Note: Requirements - nektos/act uses Docker to run your workflow on your machine. So, first, you need to have Docker (Docker Desktop for Mac and Windows, and Docker Engine for Linux) set up on your system.

If you use a Mac, you can use Homebrew to install it by running the following command in your terminal:

brew install act

Enter fullscreen mode Exit fullscreen mode

Run your workflow

To run your workflow on your machine, just navigate to your repository folder and run command act at the terminal. It will run all workflows that are triggered by a GitHub push event in your .github/workflows folder. Run command act

Conclusion

act is a valuable tool for developers who regularly work with GitHub Actions and want to test and debug their workflows locally.

NB:

If you encounter this error :

error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: 

Enter fullscreen mode Exit fullscreen mode

executable file not found in $PATH

Update the in ~/.docker/config.json change credsStore to credStore

Top comments (0)