| name | act |
| description | Test GitHub Actions locally using act. Use when debugging workflows locally, testing workflow changes before pushing, or troubleshooting action failures. |
act - Local GitHub Actions Testing
Activate when testing GitHub Actions workflows locally, debugging workflow issues, or developing actions without committing to remote repositories. This skill covers act installation, configuration, and usage patterns.
When to Use This Skill
Activate when:
- Testing workflow changes before committing
- Debugging workflow failures locally
- Developing new workflows iteratively
- Validating workflow syntax and logic
- Testing actions with different events
- Running workflows without GitHub runners
- Troubleshooting act-specific issues
Installation
Using mise (Recommended for this project)
The act tool is configured in the github plugin's mise.toml:
mise install act
act --version
Alternative Installation Methods
macOS (Homebrew):
brew install act
Linux (via script):
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
From source:
git clone https://github.com/nektos/act.git
cd act
make install
Windows (Chocolatey):
choco install act-cli
How act Works
act reads workflow files from .github/workflows/ and:
- Determines which actions and jobs to execute
- Pulls or builds required Docker images
- Creates containers matching GitHub's runner environment
- Executes steps in isolated containers
- Provides output matching GitHub Actions format
Key Concept: act uses Docker to simulate GitHub's runner environment locally.
Prerequisites
- Docker: act requires Docker to run workflows
- Workflow files: Valid
.github/workflows/*.yml files in repository
Verify Docker is running:
docker ps
Basic Usage
List Available Workflows
act -l
Run Default Event (push)
act
act -j build
act -W .github/workflows/ci.yml
Run Specific Events
act pull_request
act workflow_dispatch
act push -e .github/workflows/push-event.json
act schedule
Dry Run
act -n
act -n -v
Event Payloads
Custom Event Data
Create event JSON file:
{
"pull_request": {
"number": 123,
"head": {
"ref": "feature-branch"
},
"base": {
"ref": "main"
}
}
}
Use with act:
act pull_request -e event.json
workflow_dispatch Inputs
{
"inputs": {
"environment": "staging",
"debug": true
}
}
act workflow_dispatch -e inputs.json
Secrets Management
Via Command Line
act -s GITHUB_TOKEN=ghp_xxxxx
act -s API_KEY=key123 -s DB_PASSWORD=pass456
Via .secrets File
Create .secrets file (add to .gitignore):
GITHUB_TOKEN=ghp_xxxxx
API_KEY=key123
DB_PASSWORD=pass456
Run with secrets file:
act --secret-file .secrets
Environment Variables
act -s GITHUB_TOKEN
export MY_SECRET=value
act -s MY_SECRET
Configuration
.actrc File
Create .actrc in repository root or home directory:
# Use specific platform
-P ubuntu-latest=catthehacker/ubuntu:act-latest
# Default secrets file
--secret-file .secrets
# Default environment
--env-file .env
# Container architecture
--container-architecture linux/amd64
# Verbose output
-v
Custom Runner Images
act -P ubuntu-latest=my-custom-image:latest
act -P ubuntu-latest=catthehacker/ubuntu:act-latest
act -P ubuntu-latest=node:16-buster-slim
Recommended Images
act supports different image sizes:
Medium images (recommended):
- Better compatibility with GitHub Actions
- More pre-installed tools
- Slower startup but fewer failures
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
Micro images:
- Faster startup
- Minimal pre-installed tools
- May require additional setup
Environment Variables
Via .env File
Create .env file:
NODE_ENV=test
API_URL=http://localhost:3000
LOG_LEVEL=debug
Use with act:
act --env-file .env
Via Command Line
act --env NODE_ENV=test --env API_URL=http://localhost:3000
Advanced Usage
Bind Workspace
Mount local directory into container:
act --bind
Reuse Containers
Keep containers between runs for faster execution:
act --reuse
Specific Platforms
act -P ubuntu-latest=ubuntu:latest
act -P ubuntu-latest=ubuntu:latest \
-P windows-latest=windows:latest
Container Architecture
act --container-architecture linux/amd64
Network Configuration
act --container-daemon-socket -
act --network my-network
Artifact Server
act --artifact-server-path /tmp/artifacts \
--artifact-server-port 34567
Debugging
Verbose Output
act -v
act -vv
Watch Mode
act --watch
Interactive Shell
act --shell bash
Container Inspection
docker ps -a | grep act
docker inspect <container-id>
docker logs <container-id>
Limitations and Differences
Not Supported by act
- Some GitHub-hosted runner features
- GitHub Apps and installations
- OIDC token generation
- Some GitHub API interactions
- Certain cache implementations
- Job summaries and annotations (limited)
Workarounds
Missing tools:
steps:
- name: Install missing tool
run: |
if ! command -v tool &> /dev/null; then
apt-get update && apt-get install -y tool
fi
GitHub API calls:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh api repos/${{ github.repository }}/issues
Common Patterns
Testing Pull Request Workflow
cat > pr-event.json << EOF
{
"pull_request": {
"number": 1,
"head": { "ref": "feature" },
"base": { "ref": "main" }
}
}
EOF
act pull_request -e pr-event.json -j test
CI/CD Pipeline Testing
act push
act push -j build
act push -j test
act push -j deploy --secret-file .secrets
Matrix Testing
act -j test
act -j test --matrix node-version:20
Workflow Development Cycle
act -l
act -n -j build
act -v -j build
act --reuse -j build
Troubleshooting
Docker Issues
Error: Cannot connect to Docker daemon
sudo systemctl start docker
Error: Permission denied
sudo usermod -aG docker $USER
newgrp docker
Image Pull Issues
Error: Failed to pull image
act -P ubuntu-latest=ubuntu:22.04
act -P ubuntu-latest=catthehacker/ubuntu:act-latest
Workflow Not Found
Error: No workflows found
ls -la .github/workflows/
act -n -v
Secret Issues
Error: Secret not found
grep -r "secrets\." .github/workflows/
act -s SECRET_NAME=value
act --secret-file .secrets
Action Failures
Error: Action not found or fails
- name: Problematic step
if: github.event_name != 'act'
uses: some/action@v1
Platform Differences
Error: Command not found
act -P ubuntu-latest=catthehacker/ubuntu:act-latest
- run: apt-get update && apt-get install -y <tool>
Best Practices
.actrc Configuration
Create .actrc in repository:
-P ubuntu-latest=catthehacker/ubuntu:act-latest
--secret-file .secrets
--container-architecture linux/amd64
--artifact-server-path /tmp/artifacts
.gitignore Entries
# act secrets and config
.secrets
.env
# act artifacts
/tmp/artifacts/
Conditional Logic for Local Testing
steps:
- name: Deploy
if: github.event_name != 'act'
run: ./deploy.sh
- name: Local setup
if: github.event_name == 'act'
run: ./local-setup.sh
Fast Feedback Loop
act --reuse -j test
act -j my-new-job -v
act --watch -j test
Integration with Development Workflow
Pre-commit Testing
act -j test && git commit -m "message"
act -j test --quiet
Quick Validation
act -n
act -j affected-job
CI Parity
act -P ubuntu-latest=ubuntu:22.04
act --secret-file .secrets
Scripts and Automation
Installation Script
The plugin includes an installation script at scripts/install-act.sh:
#!/usr/bin/env bash
if command -v mise &> /dev/null; then
echo "Installing act via mise..."
mise install act
elif [[ "$OSTYPE" == "darwin"* ]] && command -v brew &> /dev/null; then
echo "Installing act via Homebrew..."
brew install act
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Installing act via install script..."
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
else
echo "Please install act manually: https://github.com/nektos/act"
exit 1
fi
act --version
Run with:
chmod +x scripts/install-act.sh
./scripts/install-act.sh
Anti-Fabrication Requirements
- Execute
act --version before documenting version numbers
- Use
act -l to verify actual workflows before claiming their presence
- Execute
docker ps to confirm Docker is running before troubleshooting
- Run
act -n to validate workflow syntax before claiming correctness
- Execute actual
act commands to verify behavior before documenting output format
- Use
docker images to verify available images before recommending specific versions
- Never claim success rates or performance metrics without actual measurement
- Execute
act -v to observe actual error messages before documenting troubleshooting steps
- Use Read tool to verify workflow files exist before testing them with act
- Run actual event payloads through act before claiming they work correctly