Loading...
Loading...
Use when testing GitHub Actions workflows locally with act. Covers act CLI usage, Docker configuration, debugging workflows, and troubleshooting common issues when running workflows on your local machine.
npx skill4agent add thebushidocollective/han act-local-testingbrew install actcurl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bashchoco install act-cli
# or
scoop install actgo install github.com/nektos/act@latest# Run workflows triggered by push event
act
# Equivalent to
act push# Pull request event
act pull_request
# Workflow dispatch
act workflow_dispatch
# Custom event
act repository_dispatch -e event.json# Run specific workflow file
act -W .github/workflows/ci.yml
# Run specific job
act -j build
# Run specific workflow and job
act -W .github/workflows/deploy.yml -j production# List all workflows and jobs
act -l
# List for specific event
act pull_request -l# Validate without executing
act --dryrun
# Show what would run
act -n
# Validate specific workflow
act --dryrun -W .github/workflows/ci.yml# Show workflow graph
act -g
# Show graph for specific event
act pull_request -g# Use default images (micro - minimal)
act
# Use medium images (more tools)
act -P ubuntu-latest=catthehacker/ubuntu:act-latest
# Use large images (most compatible)
act -P ubuntu-latest=catthehacker/ubuntu:full-latest.actrc-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04act -P ubuntu-latest=node:18 \
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04# Reuse containers between runs (faster)
act --reuse
# Clean up after run
act --rm.secretsGITHUB_TOKEN=ghp_your_token_here
NPM_TOKEN=npm_your_token_here
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret.gitignore.secretsact --secret-file .secrets# Single secret
act -s GITHUB_TOKEN=ghp_token
# Multiple secrets
act -s GITHUB_TOKEN=ghp_token \
-s NPM_TOKEN=npm_token# Development secrets
act --secret-file .secrets.dev
# Production secrets
act --secret-file .secrets.prod# Single variable
act --env NODE_ENV=development
# Multiple variables
act --env NODE_ENV=development \
--env DEBUG=true.envNODE_ENV=development
DEBUG=true
LOG_LEVEL=debugact --env-file .envGITHUB_ACTOR=nektos/act
GITHUB_REPOSITORY=owner/repo
GITHUB_EVENT_NAME=push
GITHUB_SHA=abc123...
GITHUB_REF=refs/heads/main
ACT=true# Verbose mode
act -v
# Very verbose (debug)
act -vv# Interactive mode - pause before each step
act --watch# Keep container running after workflow
act --reuse
# Then in another terminal
docker ps
docker exec -it <container-id> /bin/bash# Mount current directory
act --bind
# Mount specific directory
act -b /host/path:/container/path# Validate workflow syntax
act --dryrun
# Run tests
act -j test
# Run full CI
act# Edit workflow
vim .github/workflows/ci.yml
# Test immediately
act --reuse -j build
# Iterate quickly
act --reuse -j build# Run specific matrix combination
act --matrix os:ubuntu-latest --matrix node:20
# Run all combinations
act# Check Docker is running
docker ps
# Pull required images manually
docker pull catthehacker/ubuntu:act-latest
# Clean up Docker resources
docker system prune -a# Run with sudo (Linux)
sudo act
# Fix Docker permissions (Linux)
sudo usermod -aG docker $USER
newgrp docker# Use fuller image
act -P ubuntu-latest=catthehacker/ubuntu:full-latest
# Or install in workflow
- run: |
apt-get update
apt-get install -y some-tool# Check workflow files exist
ls -la .github/workflows/
# Validate YAML syntax
yamllint .github/workflows/*.yml
# List detected workflows
act -l# Skip action in act
- name: GitHub-only action
if: ${{ !env.ACT }}
uses: github/some-action@v1
# Use alternative in act
- name: Local alternative
if: env.ACT == 'true'
run: echo "Running local version"act --dryrun.actrc.secrets.gitignore--reuse.secrets.envlatest--dryrun# Platform mappings
-P ubuntu-latest=catthehacker/ubuntu:act-latest
# Default options
--reuse
--secret-file .secrets
--env-file .env
# Container options
--container-architecture linux/amd64.git/hooks/pre-push#!/bin/bash
echo "Validating workflows..."
act --dryrun
if [ $? -ne 0 ]; then
echo "Workflow validation failed"
exit 1
fi.PHONY: test-workflows
test-workflows:
act --dryrun
act -j test
.PHONY: ci-local
ci-local:
act --reuse# Use reuse flag
act --reuse
# Skip checkout if not needed
act --reuse -j test --no-recurse
# Use smaller images for simple tests
act -P ubuntu-latest=node:20-alpine- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}~/.cache/act/