03 Feb 2026

Running GitHub Actions locally with act

Giang Nguyen

Giang Nguyen

Read in Vietnamese
Running GitHub Actions locally with act

GitHub Actions is a common way to automate tests for a bioinformatics repository, but each run has to be pushed to GitHub and scheduled on a cloud runner, so the feedback loop is measured in minutes. act is a command-line tool that runs GitHub Actions workflows locally using Docker, which makes it possible to test a workflow before pushing it.

This post covers installation, the commands used most often, how secrets and environment variables are handled, the Docker images involved, and a few debugging techniques. The examples are generic pipelines; the same approach applies to a gene-expression or quality-control workflow.

Why run workflows locally

The usual loop is:

  1. Write or edit a workflow file, then push to GitHub
  2. Wait for the cloud runner to pick up the job
  3. If the workflow fails, fix it locally and push again
  4. Repeat steps 2 and 3 as needed

With act, step 2 is replaced by a local run: the workflow is executed on the developer's machine, so several iterations can be completed before anything is pushed. The exact saving in time depends on the workflow and the machine, but the main benefit is that a broken workflow is often caught sooner.

Part 1: Installation and setup

Step 1: Install act with Pixi

One way to install act globally is with Pixi, a package manager that can install both Python packages and system tools:

Terminal window
pixi global install act

Pixi selects the correct binary for the operating system (macOS, Linux or Windows).

Verify the installation:

Terminal window
act --version
# Output: act version 0.2.X

Reasons this can be convenient:

  • cross-platform (macOS, Linux, Windows)
  • no additional system dependencies
  • a single command: pixi global install act
  • updates via pixi global upgrade act
  • isolated from the system Python and its packages
  • the same tool can manage the project environment

Alternative installation methods

macOS (Homebrew)

Terminal window
brew install act

Linux

Terminal window
# Debian/Ubuntu
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | bash
# Or with pacman (Arch)
pacman -S act

Windows (PowerShell)

Terminal window
choco install act
# Or if using Scoop:
scoop install act

Manual installation

  • download from the GitHub Releases page
  • extract the binary to a directory in $PATH

Step 2: Install Docker

act uses Docker to run workflows in containers, in a similar way to GitHub's cloud runners.

Option 1: Docker Desktop

  • download Docker Desktop for macOS or Windows
  • install and start the application
  • Docker should then be available in the terminal

Option 2: Install the Docker tools with Pixi

Terminal window
# Install Docker tools in your Pixi environment
pixi global install docker

Option 3: Linux system package

Terminal window
# Debian/Ubuntu
sudo apt-get install docker.io docker-compose
sudo usermod -aG docker $USER # Add current user to docker group
newgrp docker # Activate group changes

Verify the Docker installation:

Terminal window
docker --version
docker run hello-world # Should complete successfully

Troubleshooting:

  • macOS/Windows: make sure Docker Desktop is running
  • Linux: check that the daemon is running with sudo systemctl start docker
  • permission denied: add the user to the docker group with sudo usermod -aG docker $USER

Step 3: Verify the setup

Check that act can find the workflows in the repository:

Terminal window
cd /path/to/your/repo
act --list

Expected output:

Stage Job ID Job Name Workflow Name Workflow File Events
0 test test test-workflow .github/workflows/test.yml push

If no workflows appear, check that .github/workflows/ exists and contains .yml files.

Step 4: Pixi integration (optional)

If the project uses Pixi, act can be added as a task:

Add to pixi.toml:

[tasks]
ci = "act push"
ci-test = "act pull_request"
ci-debug = "act -v push"

Then run with Pixi:

Terminal window
pixi run ci # Run GitHub Actions locally
pixi run ci-debug # With verbose output

Check the Pixi setup:

Terminal window
pixi info
# Should show: act is available globally

Part 2: Basic usage

A minimal Python test workflow

A small GitHub Actions workflow to test with act:

Create .github/workflows/test.yml:

name: Python Tests
on:
push:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
pip install pytest numpy pandas
- name: Run tests
run: |
pytest tests/ -v

Run it locally:

Terminal window
act push

Expected output:

[Python Tests/test] πŸš€ Start image pull...
[Python Tests/test] 🐳 Docker pull requested ghcr.io/catthehacker/ubuntu:act-latest
[Python Tests/test] βœ“ Image pull complete
[Python Tests/test] πŸš€ Start container...
[Python Tests/test] ⭐ Run Main actions/checkout@v3
[Python Tests/test] βœ“ Complete job

Running a specific workflow or job

List the available workflows:

Terminal window
act --list

Run a specific job:

Terminal window
act --job test

Run a specific workflow:

Terminal window
act --workflow test.yml

Simulate a different event (for example, pull_request):

Terminal window
act pull_request

Part 3: Environment variables and secrets

Passing environment variables

act provides several ways to pass variables.

Method 1: command-line flag

Terminal window
act -e event.json

Where event.json contains:

{
"repository": {
"name": "my-repo",
"owner": {
"login": "myusername"
}
}
}

Method 2: .actrc file (in the repository root)

.actrc
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest
-l

Method 3: shell environment variables

Terminal window
export MY_VAR="value"
export ANOTHER_VAR="another"
act push

Working with secrets

GitHub Actions uses secrets for sensitive data. With act, secrets can be passed locally.

Method 1: .secrets file (in the repository root)

.secrets
MY_SECRET=super_secret_value
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
API_KEY=your_api_key_here

Add .secrets to .gitignore so it is not committed:

Terminal window
echo ".secrets" >> .gitignore

Method 2: command-line secret flag

Terminal window
act -s MY_SECRET=value -s GITHUB_TOKEN=token

A workflow that uses secrets:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use secret
run: |
echo "API Key: ${{ secrets.API_KEY }}"
echo "Token: ${{ secrets.GITHUB_TOKEN }}"

Run with secrets:

Terminal window
act --secret-file .secrets

The echo example above prints a secret value to the log. It is shown here only to illustrate how secrets are referenced; avoid echoing real secrets in a workflow that runs anywhere but a disposable local container.

Part 4: Docker and container images

Container images used by act

act uses prebuilt Docker images that mimic GitHub's cloud runners. The default images are large, which improves compatibility with the tools a workflow expects.

Available images:

Terminal window
# Ubuntu (medium size, the default choice)
ghcr.io/catthehacker/ubuntu:act-latest
# Full Ubuntu (largest, closest to a GitHub cloud runner)
ghcr.io/catthehacker/ubuntu:full-latest
# Official Ubuntu (smallest, but only the base system)
ubuntu:latest # Docker Hub

Specifying the image

Method 1: -P flag in the command

Terminal window
act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-latest

Method 2: .actrc file

.actrc
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-latest
-P windows-latest=ghcr.io/catthehacker/windows:full-latest

Selecting the container architecture

Terminal window
act --container-architecture linux/amd64

Pre-pulling images

Large images take time on the first run. They can be pulled ahead of time:

Terminal window
# Pull the image once
docker pull ghcr.io/catthehacker/ubuntu:act-latest
# Now act will use cached image (much faster)
act push

Managing disk space

Docker images consume space. Unused images can be removed with:

Terminal window
# Remove unused images
docker image prune -a
# Remove all containers
docker container prune -a
# Check disk usage
docker system df

Part 5: Performance notes

1. Choosing a smaller image

The catthehacker images are published in several sizes. A smaller image pulls and starts faster, but has fewer tools preinstalled, so startup may be quicker while setup steps take longer.

Terminal window
act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest

2. Caching dependencies

GitHub Actions supports caching, and act can use the same mechanism:

Workflow with caching:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Run tests
run: pytest tests/

A cache hit typically skips most of the dependency installation.

3. Running jobs in parallel

By default, act runs jobs sequentially. Parallel execution can be enabled:

Terminal window
# Run all jobs in parallel
act --parallel 4

Workflow with multiple jobs:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- run: pytest tests/unit/
integration-tests:
runs-on: ubuntu-latest
steps:
- run: pytest tests/integration/
lint:
runs-on: ubuntu-latest
steps:
- run: pylint src/

The wall-clock time then depends on the slowest job rather than the sum of all jobs.

4. Listing jobs without running them

Terminal window
act --list

This shows the jobs that would run, without executing them.

5. Reusing or rebuilding containers

Terminal window
act --reuse-containers # Reuse running containers
act --rebuild # Rebuild image from scratch

An extended example: a gene-expression pipeline

The following workflow illustrates a multi-version test matrix and a separate security job.

Workflow file: .github/workflows/ml-pipeline.yml

name: ML Pipeline - Gene Expression Analysis
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-xdist
- name: Lint with pylint
run: pylint src/ --exit-zero
continue-on-error: true
- name: Run unit tests
run: pytest tests/unit/ -v --cov=src --cov-report=xml
- name: Run integration tests
run: pytest tests/integration/ -v
- name: Upload coverage reports
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.12'
with:
files: ./coverage.xml
flags: unittests
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Bandit security check
run: |
pip install bandit
bandit -r src/ -v --exit-code 0
continue-on-error: true

Running it locally

Run all jobs:

Terminal window
act push

Run a specific Python version:

Terminal window
act push --job test --matrix python-version=3.12

Run only the security job:

Terminal window
act push --job security

Debugging workflows

Verbose logging

Terminal window
act -v push

This prints more detail, including Docker commands and environment variables.

Interactive inspection

If a step fails, the container can be inspected. A diagnostic step can be added to a workflow:

steps:
- run: |
echo "Debug info:"
env | sort
ls -la

Or act can be run with the working directory bound into the container:

Terminal window
act -b # Bind the working directory into the container

Inspecting a container after a failure

Terminal window
# View logs
docker ps -a
# Enter the container
docker exec -it <container_id> /bin/bash

Common issues

"Cannot connect to Docker daemon"

Terminal window
# Solution: Start Docker
sudo systemctl start docker # Linux
open /Applications/Docker.app # macOS

"Not enough space for Docker images"

Terminal window
# Solution: Clean up
docker system prune -a --volumes

"Workflow runs but tests fail locally but pass on GitHub"

Terminal window
# Solution: Check Python versions match
python --version
act --list # Verify Python version in workflow

Local vs cloud: an illustrative comparison

The table below is illustrative rather than a benchmark; actual times depend on the workflow, the machine and the network.

Task Local (act) GitHub Cloud
First run (image already pulled) tens of seconds several minutes
Subsequent runs (cached) a few seconds minutes
Development iteration short loop longer loop
Cost machine time only cloud runner minutes

For a development session with many small iterations, the cumulative time saved can be substantial, mainly because a failing workflow is usually found before pushing.

Practices for using act

1. Test before pushing

Terminal window
# Before git push
act push
# If all pass, then:
git push origin main

2. Match the GitHub runner environment

Terminal window
# Use same image as GitHub
act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest

3. Commit .actrc, but never .secrets

Terminal window
# .actrc (can be committed)
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-latest
-l
.gitignore
.secrets

4. Use a matrix for multiple versions

strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest]

5. Document dependencies

Terminal window
# requirements.txt
pytest>=7.0.0
numpy>=1.24.0
pandas>=1.5.0
scipy>=1.10.0

6. Keep global tools in Pixi

If Pixi manages the project, global tools can live there too:

Terminal window
# Install act globally with Pixi
pixi global install act
# Update act easily
pixi global upgrade act
# See all globally installed tools
pixi global list

A .pixi.toml for the project:

[dependencies]
python = "3.12"
pytest = ">=7.0.0"
numpy = ">=1.24.0"
pandas = ">=1.5.0"
[tasks]
test = "pytest tests/ -v"
lint = "pylint src/"
ci = "act push" # Run GitHub Actions locally

The team can then run:

Terminal window
pixi run test # Run tests
pixi run lint # Run linter
pixi run ci # Run GitHub Actions locally

Summary

  • act runs GitHub Actions workflows locally, so a workflow can be tested before pushing.
  • The feedback loop is shorter than waiting for a cloud runner, which makes iteration easier.
  • It is Docker-based, so the local container resembles a GitHub cloud runner.
  • Secrets and environment variables can be passed, so realistic workflows can be tested.
  • Choosing an image, caching and parallel jobs all affect how long a local run takes.

References