-
Notifications
You must be signed in to change notification settings - Fork 15
Add act tool for local GitHub Actions testing #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,132 @@ | ||||||||||||||||||||||||||||||||||
| # act | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Run your GitHub Actions locally! `act` is a command-line tool that allows you to test and debug GitHub Actions workflows on your local machine using Docker. It eliminates the need to commit and push changes to GitHub just to test workflow modifications, significantly speeding up the development cycle for CI/CD pipelines. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Key Features | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - **Local Workflow Execution**: Run GitHub Actions workflows locally without pushing to GitHub | ||||||||||||||||||||||||||||||||||
| - **Docker-Based**: Uses Docker containers to simulate GitHub-hosted runners | ||||||||||||||||||||||||||||||||||
| - **Event Simulation**: Trigger workflows with custom event payloads | ||||||||||||||||||||||||||||||||||
| - **Secret Management**: Support for environment variables and secrets locally | ||||||||||||||||||||||||||||||||||
| - **Fast Iteration**: Test workflow changes instantly without waiting for cloud runners | ||||||||||||||||||||||||||||||||||
| - **Multiple Runner Images**: Supports ubuntu, macos, and windows runner environments | ||||||||||||||||||||||||||||||||||
| - **Workflow Debugging**: Step through workflow execution to identify issues quickly | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Getting Started | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Installation | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
| # macOS | ||||||||||||||||||||||||||||||||||
| brew install act | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Linux | ||||||||||||||||||||||||||||||||||
| curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Windows (using Chocolatey) | ||||||||||||||||||||||||||||||||||
| choco install act-cli | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Using Go | ||||||||||||||||||||||||||||||||||
| go install github.com/nektos/act@latest | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Basic Usage | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
| # List available workflows in current repository | ||||||||||||||||||||||||||||||||||
| act -l | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run the default event (push) | ||||||||||||||||||||||||||||||||||
| act | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run a specific workflow event | ||||||||||||||||||||||||||||||||||
| act pull_request | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run a specific job | ||||||||||||||||||||||||||||||||||
| act -j test | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run with custom event payload | ||||||||||||||||||||||||||||||||||
| act -e event.json | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Use a specific runner image | ||||||||||||||||||||||||||||||||||
| act -P ubuntu-latest=catthehacker/ubuntu:act-latest | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run a specific workflow file | ||||||||||||||||||||||||||||||||||
| act -W .github/workflows/ci.yml | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Example: Testing a Workflow Locally | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Create a simple workflow file `.github/workflows/test.yml`: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ```yaml | ||||||||||||||||||||||||||||||||||
| name: Test Workflow | ||||||||||||||||||||||||||||||||||
| on: [push] | ||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||
| test: | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v3 | ||||||||||||||||||||||||||||||||||
| - name: Run tests | ||||||||||||||||||||||||||||||||||
| run: echo "Running tests..." | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Test it locally: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
| # Run the push event workflow | ||||||||||||||||||||||||||||||||||
| act push | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run a specific workflow file with a specific event | ||||||||||||||||||||||||||||||||||
| act push -W .github/workflows/test.yml | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Dry run to see what would happen | ||||||||||||||||||||||||||||||||||
| act -n | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run with verbose output | ||||||||||||||||||||||||||||||||||
| act -v | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #### Example Output | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| When running the test workflow, you'll see output similar to this: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Working with Secrets | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
| # Create .secrets file | ||||||||||||||||||||||||||||||||||
| echo "GITHUB_TOKEN=your_token" > .secrets | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Run workflow with secrets | ||||||||||||||||||||||||||||||||||
| act --secret-file .secrets | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Or pass secrets as environment variables | ||||||||||||||||||||||||||||||||||
| act -s GITHUB_TOKEN=your_token | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### Using Custom Runner Images | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||
| # Use a smaller image for faster execution | ||||||||||||||||||||||||||||||||||
| act -P ubuntu-latest=node:16-buster-slim | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Configure default platforms in .actrc | ||||||||||||||||||||||||||||||||||
| cat > ~/.actrc << EOF | ||||||||||||||||||||||||||||||||||
| -P ubuntu-latest=catthehacker/ubuntu:act-latest | ||||||||||||||||||||||||||||||||||
| -P ubuntu-20.04=catthehacker/ubuntu:act-20.04 | ||||||||||||||||||||||||||||||||||
| -P ubuntu-18.04=catthehacker/ubuntu:act-18.04 | ||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Resources | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - **Documentation & User Guide**: https://nektosact.com/introduction.html | ||||||||||||||||||||||||||||||||||
| - **Official GitHub Repository**: https://github.com/nektos/act | ||||||||||||||||||||||||||||||||||
| - **Releases**: https://github.com/nektos/act/releases | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+127
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix Resources section formatting to match project standards. The Resources section has two formatting issues:
Compare with Apply this diff to fix formatting: ## Resources
- - **Documentation & User Guide**: https://nektosact.com/introduction.html
- - **Official GitHub Repository**: https://github.com/nektos/act
- - **Releases**: https://github.com/nektos/act/releases
+ - [Documentation & User Guide](https://nektosact.com/introduction.html)
+ - [Official GitHub Repository](https://github.com/nektos/act)
+ - [Releases](https://github.com/nektos/act/releases)📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)129-129: Unordered list indentation (MD007, ul-indent) 129-129: Bare URL used (MD034, no-bare-urls) 130-130: Unordered list indentation (MD007, ul-indent) 130-130: Bare URL used (MD034, no-bare-urls) 131-131: Unordered list indentation (MD007, ul-indent) 131-131: Bare URL used (MD034, no-bare-urls) 🤖 Prompt for AI Agents
Comment on lines
+129
to
+131
|
||||||||||||||||||||||||||||||||||
| - **Documentation & User Guide**: https://nektosact.com/introduction.html | |
| - **Official GitHub Repository**: https://github.com/nektos/act | |
| - **Releases**: https://github.com/nektos/act/releases | |
| - [Documentation](https://nektosact.com/introduction.html) | |
| - [GitHub Repository](https://github.com/nektos/act) | |
| - [Releases](https://github.com/nektos/act/releases) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL in the Documentation & User Guide link appears to be incorrect. The URL
https://nektosact.com/introduction.htmlis missing a dot between "nektos" and "act". It should behttps://nektosact.com/or more likelyhttps://nektos.github.io/act/based on the actual documentation location for the nektos/act project.