To Nha Notes | Aug. 13, 2024, 6:25 p.m.
GitHub Actions is a powerful tool for automating your software development workflows. It allows you to define custom workflows in YAML files that execute various tasks, such as building, testing, and deploying your code. However, testing these workflows before pushing them to your repository can be challenging. That’s where the act CLI comes in handy.
The act CLI is an open-source tool that simulates GitHub Actions locally. It allows you to run your workflows on your local machine, providing a faster feedback loop during development. Here’s how to get started:
Before you begin, make sure you have the following installed:
Docker: The act CLI relies on Docker to create isolated environments for running your workflows. Install Docker from here.
act CLI:
curl -s "https://raw.githubusercontent.com/nektos/act/master/install.sh" | sudo bash
Navigate to Your Project Directory: Open a terminal and navigate to the root directory of your GitHub repository.
Run act:
Choose a Docker Image:
Iterate and Test:
The act CLI provides several useful commands for working with GitHub Actions locally. Here are some key ones:
List All Actions: To view all available actions defined in your .github/workflows directory, run:
act -l
Run a Specific Action: To run a specific action (e.g., the build action), use:
act build
Run Specific Jobs: You can execute a specific job from your workflows using the --job option:
act --job my-job-name
The act CLI is a valuable tool for GitHub Actions development. By running workflows locally, you can catch errors early and streamline your CI/CD process.
https://overcast.blog/run-the-github-actions-workflow-locally-a-complete-guide-8592e3169d48