act Setup - Local GitHub Actions Testing
act lets you run GitHub Actions locally, providing fast feedback without pushing commits or waiting for GitHub-hosted runners.
Prerequisites
- Docker installed and running (act uses containers to run workflows)
- On macOS:
docker --versionshould return the version - If Docker isn’t running, you’ll see: “Cannot connect to the Docker daemon”
- On macOS:
Why Use act?
- Fast iteration - Test workflow changes in seconds, not minutes
- No commit noise - Fix issues before pushing to GitHub
- Cost savings - No GitHub Actions minutes consumed during testing
- Secrets safety - Test with real credentials locally without exposing them in GitHub logs
Installation
macOS (Homebrew)
brew install actOther Platforms
See nektos/act releases for binaries or install via:
# GitHub CLI extension
gh extension install nektos/gh-act
# Or use the install script
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bashConfiguration
1. Copy secrets template
cp .secrets.example .secretsEdit .secrets and add your actual tokens:
GITHUB_TOKEN=ghp_your_personal_access_token
SLACK_BOT_TOKEN=xoxb_your_slack_bot_token
Get your tokens:
- GitHub Token: github.com/settings/tokens - needs
repoandworkflowscopes - Slack Bot Token: From 1Password (Brainforge AI Team vault) or Slack app settings
2. Review .actrc (optional)
The repo includes a .actrc file with sensible defaults:
-P ubuntu-latest=catthehacker/ubuntu:act-latest
--secret-file .secrets
--rm
Basic Usage
List available workflows
act -lRun a specific workflow
# Run workflow_dispatch event for daily-platform-summary
act workflow_dispatch -W .github/workflows/daily-platform-summary.yml
# Run a specific job
act workflow_dispatch -j post-summaryRun with specific secrets
act workflow_dispatch -j post-summary --secret-file .secretsDry run (see what would execute)
act -n workflow_dispatchVerbose output
act -v workflow_dispatchTesting the Daily Platform Summary Workflow
Prerequisites
-
Ensure
.secretshas valid tokens:GITHUB_TOKEN- for fetching merged PRsSLACK_BOT_TOKEN- for posting to Slack
-
The workflow uses
ubuntu-latestwhich maps tocatthehacker/ubuntu:act-latest(pre-installed with curl, jq, etc.)
Run the test
act workflow_dispatch -j post-summaryExpected behavior
- Workflow fetches PRs merged in last 24h from GitHub API
- Constructs Slack message payload using
jq - Posts to
#platformchannel (C08CRQJ636X) - Prints success or error message
Common issues
| Issue | Solution |
|---|---|
jq: command not found | Use -P ubuntu-latest=catthehacker/ubuntu:act-latest |
SLACK_BOT_TOKEN not set | Ensure .secrets file exists and has the token |
channel_not_found | Bot not in channel - invite it in Slack |
invalid_arguments | Malformed JSON - check jq syntax in workflow |
Pro Tips
Test without posting to Slack
Temporarily change the curl command in the workflow to echo instead of POST:
echo "$SLACK_PAYLOAD" | jq .Test specific PR scenarios
Modify the SINCE_TIMESTAMP calculation to look at a specific date range:
# Look at last 7 days instead of 24h
SINCE_TIMESTAMP=$(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ)Debug jq issues
Add set -x to the workflow run script for verbose shell output.
CI/CD Integration
Consider adding an act step to your pre-commit hooks or local CI script:
#!/bin/bash
# test-workflows.sh
echo "Testing GitHub Actions locally..."
act workflow_dispatch -j post-summary -q || exit 1