| name | act-local-testing |
| user-invocable | false |
| description | 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. |
| allowed-tools | ["Read","Write","Edit","Bash","Grep","Glob"] |
Act - Local Workflow Testing
Use this skill when testing GitHub Actions workflows locally with act. This covers act CLI commands, Docker setup, debugging, and best practices for fast local iteration on CI/CD workflows.
Installation
macOS
brew install act
Linux
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
Windows
choco install act-cli
scoop install act
From Source
go install github.com/nektos/act@latest
Basic Usage
Run All Workflows
act
act push
Run Specific Events
act pull_request
act workflow_dispatch
act repository_dispatch -e event.json
Run Specific Workflows
act -W .github/workflows/ci.yml
act -j build
act -W .github/workflows/deploy.yml -j production
List Available Workflows
act -l
act pull_request -l
Validation and Dry Runs
Dry Run
act --dryrun
act -n
act --dryrun -W .github/workflows/ci.yml
Graph Visualization
act -g
act pull_request -g
Docker Configuration
Default Runners
Act uses Docker images to simulate GitHub's runners:
act
act -P ubuntu-latest=catthehacker/ubuntu:act-latest
act -P ubuntu-latest=catthehacker/ubuntu:full-latest
Custom Platform Images
Create .actrc file in project root:
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
Or use command line:
act -P ubuntu-latest=node:18 \
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
Reusing Docker Containers
act --reuse
act --rm
Secrets Management
Using .secrets File
Create .secrets in project root:
GITHUB_TOKEN=ghp_your_token_here
NPM_TOKEN=npm_your_token_here
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
Add to .gitignore:
.secrets
Run with secrets:
act --secret-file .secrets
Inline Secrets
act -s GITHUB_TOKEN=ghp_token
act -s GITHUB_TOKEN=ghp_token \
-s NPM_TOKEN=npm_token
Environment-Specific Secrets
act --secret-file .secrets.dev
act --secret-file .secrets.prod
Environment Variables
Setting Variables
act --env NODE_ENV=development
act --env NODE_ENV=development \
--env DEBUG=true
Using .env File
Create .env file:
NODE_ENV=development
DEBUG=true
LOG_LEVEL=debug
Run with env file:
act --env-file .env
GitHub Context Variables
Act automatically sets these:
GITHUB_ACTOR=nektos/act
GITHUB_REPOSITORY=owner/repo
GITHUB_EVENT_NAME=push
GITHUB_SHA=abc123...
GITHUB_REF=refs/heads/main
ACT=true
Debugging
Verbose Output
act -v
act -vv
Step-by-Step Execution
act --watch
Inspect Containers
act --reuse
docker ps
docker exec -it <container-id> /bin/bash
Bind Mount Local Files
act --bind
act -b /host/path:/container/path
Common Workflows
Test Before Push
act --dryrun
act -j test
act
Iterative Development
vim .github/workflows/ci.yml
act --reuse -j build
act --reuse -j build
Matrix Testing
act --matrix os:ubuntu-latest --matrix node:20
act
Troubleshooting
Docker Issues
docker ps
docker pull catthehacker/ubuntu:act-latest
docker system prune -a
Permission Issues
sudo act
sudo usermod -aG docker $USER
newgrp docker
Missing Tools
act -P ubuntu-latest=catthehacker/ubuntu:full-latest
- run: |
apt-get update
apt-get install -y some-tool
Workflow Not Found
ls -la .github/workflows/
yamllint .github/workflows/*.yml
act -l
Action Compatibility
Some actions don't work with act:
- name: GitHub-only action
if: ${{ !env.ACT }}
uses: github/some-action@v1
- name: Local alternative
if: env.ACT == 'true'
run: echo "Running local version"
Best Practices
DO
✅ Use act --dryrun before running full workflows
✅ Create .actrc for consistent configuration
✅ Use .secrets file and add it to .gitignore
✅ Use --reuse for faster iteration
✅ Test workflows locally before pushing
✅ Use appropriate image sizes for your needs
✅ Document act usage in README
DON'T
❌ Commit .secrets or .env files
❌ Use latest Docker tags in production
❌ Skip validation with --dryrun
❌ Run act without understanding what it will do
❌ Ignore Docker disk space usage
❌ Assume all actions work perfectly with act
Configuration Files
.actrc
# Platform mappings
-P ubuntu-latest=catthehacker/ubuntu:act-latest
# Default options
--reuse
--secret-file .secrets
--env-file .env
# Container options
--container-architecture linux/amd64
.github/workflows/.actrc
Project-specific overrides in workflows directory.
CI/CD Integration
Pre-Push Hook
.git/hooks/pre-push:
#!/bin/bash
echo "Validating workflows..."
act --dryrun
if [ $? -ne 0 ]; then
echo "Workflow validation failed"
exit 1
fi
Make Target
.PHONY: test-workflows
test-workflows:
act --dryrun
act -j test
.PHONY: ci-local
ci-local:
act --reuse
Performance Tips
Faster Iteration
act --reuse
act --reuse -j test --no-recurse
act -P ubuntu-latest=node:20-alpine
Caching
Act respects GitHub Actions caching:
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Cache location on host: ~/.cache/act/
Related Skills
- act-workflow-syntax: Creating and structuring workflow files
- act-docker-setup: Configuring Docker for act
- act-advanced-features: Advanced act usage patterns