Running GitHub Actions Locally

You can locally test the GitHub Actions defined in this your project using nektos act.

Setup

Simply run:

act

Apple Silcon

If running on Apple Silicon (ARM), launch act with this flag:

   act --container-architecture linux/amd64

Without this flag, I saw this warning:

WARN  ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠

and this error:

...   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir=
| docker compose build
[+] Building 0.0s (0/0)                                                         
| permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied
...

Usage

To get a list of available jobs, run:

    $ act -l

To run a specific job, use the -j flag:

    $ act -j <job-name>

For example, to run the build job from the ci.yml file, use this command:

    $ act --workflows .github/workflows/ci.yml -j build