### Install act using curl and bash Source: https://nektosact.com/installation/index.html Installs a pre-built `act` executable using a curl command to download and execute an installation script. This is a quick way to get `act` on any system with bash. ```bash curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash ``` -------------------------------- ### Install act from HEAD (Latest Commit) Source: https://nektosact.com/installation/homebrew.html Install the development version of 'act' directly from the latest commit. This requires a compiler to be installed; Homebrew will prompt if necessary. ```bash brew install act --HEAD ``` -------------------------------- ### Global Installation with Nix Source: https://nektosact.com/installation/nix.html Install 'act' globally using nix-env for persistent access across your system. ```bash nix-env -iA nixpkgs.act ``` -------------------------------- ### Install act using Scoop Source: https://nektosact.com/installation/scoop.html Use this command to install the 'act' tool via Scoop on Windows. ```bash scoop install act ``` -------------------------------- ### Install act using winget Source: https://nektosact.com/installation/winget.html Use this command to install the act tool on Windows via the winget package manager. Ensure winget is installed and configured on your system. ```powershell winget install nektos.act ``` -------------------------------- ### Run act using GitHub CLI Source: https://nektosact.com/installation/gh.html After installation, you can run act commands using the `gh act` prefix. Examples include running on push events or listing pull request events. ```bash gh act push ``` ```bash gh act -l pull_request ``` -------------------------------- ### Example Workflow with Inputs Source: https://nektosact.com/usage/index.html A sample GitHub Actions workflow demonstrating how to define and use workflow dispatch inputs. ```yaml __ on: workflow_dispatch: inputs: NAME: description: "A random input name for the workflow" type: string SOME_VALUE: description: "Some other input to pass" type: string jobs: test: name: Test runs-on: ubuntu-latest steps: - name: Test with inputs run: | echo "Hello ${{ github.event.inputs.NAME }} and ${{ github.event.inputs.SOME_VALUE }}!" ``` -------------------------------- ### Enable COPR Repository and Install act CLI Source: https://nektosact.com/installation/copr.html Enable the COPR repository for act CLI and install the package using dnf. ```bash dnf copr enable goncalossilva/act dnf install act-cli ``` -------------------------------- ### Install act-cli using Chocolatey Source: https://nektosact.com/installation/chocolatey.html Use this command to install the act-cli tool on Windows via Chocolatey. Ensure Chocolatey is installed and configured on your system. ```bash choco install act-cli ``` -------------------------------- ### Install Latest Stable Release of act Source: https://nektosact.com/installation/homebrew.html Use this command to install the most recent stable version of 'act' from Homebrew. ```bash brew install act ``` -------------------------------- ### Install act on Arch Linux Source: https://nektosact.com/installation/arch.html Use this command to install the 'act' tool on Arch Linux via the pacman package manager. ```bash pacman -Syu act ``` -------------------------------- ### Install act using MacPorts Source: https://nektosact.com/installation/macports.html Use this command to install the 'act' tool on your macOS system if you are using MacPorts. ```bash sudo port install act ``` -------------------------------- ### Act Configuration Arguments Source: https://nektosact.com/usage/index.html Example configuration arguments for '.actrc' files, specifying container architecture and offline mode. ```bash --container-architecture=linux/amd64 --action-offline-mode ``` -------------------------------- ### Example Workflow with Matrix Strategy Source: https://nektosact.com/usage/index.html A sample GitHub Actions workflow demonstrating the use of matrix strategy for running jobs across different configurations. ```yaml __ name: matrix-with-user-inclusions on: push jobs: build: name: Matrix runs-on: ubuntu-latest steps: - run: echo ${NODE_VERSION} env: NODE_VERSION: ${{ matrix.node }} strategy: matrix: os: [ubuntu-18.04, macos-latest] node: [4, 6, 8, 10] exclude: - os: macos-latest node: 4 include: - os: ubuntu-16.04 node: 10 ``` -------------------------------- ### Install act GitHub CLI Extension Source: https://nektosact.com/installation/gh.html Install the act extension using the GitHub CLI. This command adds act as a subcommand to `gh`. ```bash gh extension install https://github.com/nektos/gh-act ``` -------------------------------- ### Configure Container Architecture Source: https://nektosact.com/print.html Arguments for 'act' can be configured in '.actrc' files. This example shows how to set the container architecture to 'linux/amd64' and enable offline mode. ```bash __ --container-architecture=linux/amd64 --action-offline-mode ``` -------------------------------- ### Specify Specific Workflow File Source: https://nektosact.com/print.html This example demonstrates running all jobs within a specific workflow file, '.github/workflows/checks.yml', triggered by a 'push' event. ```bash __ act -W '.github/workflows/checks.yml' ``` -------------------------------- ### Run act within a Nix Shell Source: https://nektosact.com/installation/nix.html Use nix-shell to temporarily activate the 'act' environment without a global installation. ```bash nix-shell -p act ``` -------------------------------- ### Example JSON Payload for Workflow Dispatch Source: https://nektosact.com/print.html A sample JSON file containing inputs for triggering a workflow dispatch event. ```json { "inputs": { "NAME": "Manual Workflow", "SOME_VALUE": "ABC" } } ``` -------------------------------- ### Changing Docker Image for Ubuntu 18.04 Runner Source: https://nektosact.com/usage/runners.html Example of changing the Docker image for the `ubuntu-18.04` runner to use a specific image from `nektos/act-environments`. ```bash act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 ``` -------------------------------- ### Specify Workflow Directory Source: https://nektosact.com/print.html Use the '-W' or '--workflows' flag to specify a directory containing workflow files. This example runs all workflows in the '.github/workflows/' directory triggered by a 'push' event. ```bash __ act -W '.github/workflows/' ``` -------------------------------- ### Example JSON Payload File for Workflow Dispatch Source: https://nektosact.com/usage/index.html A sample JSON file containing input values for a workflow dispatch event, used with Act. ```json __ { "inputs": { "NAME": "Manual Workflow", "SOME_VALUE": "ABC" } } ``` -------------------------------- ### Custom Event JSON for Act Source: https://nektosact.com/usage/index.html Provides an example of a custom event.json file to control Act's behavior, specifically to allow a job to run. ```json __ { "act": true } ``` -------------------------------- ### Provide GITHUB_TOKEN using GitHub CLI Source: https://nektosact.com/print.html If the GitHub CLI is installed, you can automatically pass the GITHUB_TOKEN to 'act' using the 'gh auth token' command. ```bash __ act -s GITHUB_TOKEN="$(gh auth token)" ``` -------------------------------- ### Custom Event Payload for Act Source: https://nektosact.com/print.html Provide a custom JSON event payload to Act to simulate specific event triggers. This example uses an 'event.json' file for a push event. ```json { "act": true } ``` -------------------------------- ### Providing Inputs to Act via Input File Source: https://nektosact.com/usage/index.html Demonstrates loading workflow input values from a file using the --input-file flag, where the file format is similar to .env. ```shell act --input-file my.input ``` -------------------------------- ### Providing Inputs to Act via Command Line Source: https://nektosact.com/usage/index.html Shows how to pass input values to a workflow when running with Act using the --input flag. ```shell act --input NAME=some-value ``` -------------------------------- ### Workflow with Inputs and Act Source: https://nektosact.com/print.html Define a workflow with manual inputs and demonstrate how to pass these inputs when running with Act. ```yaml on: workflow_dispatch: inputs: NAME: description: "A random input name for the workflow" type: string SOME_VALUE: description: "Some other input to pass" type: string jobs: test: name: Test runs-on: ubuntu-latest steps: - name: Test with inputs run: | echo "Hello ${{ github.event.inputs.NAME }} and ${{ github.event.inputs.SOME_VALUE }}!" ``` -------------------------------- ### Build act from source Source: https://nektosact.com/installation/index.html Builds the `act` executable from its source code using the Go toolchain. This method requires Go 1.18+ and is useful for development or obtaining the latest unreleased versions. ```bash git clone https://github.com/nektos/act.git cd act/ make build ``` ```bash go build -ldflags "-X main.version=$(git describe --tags --dirty --always | sed -e 's/^v//')" -o dist/local/act main.go ``` -------------------------------- ### Load Repository Variables from File Source: https://nektosact.com/usage/index.html Loads repository variables from a file named 'my.variables'. The file format is compatible with '.env' files. ```bash act --var-file my.variables ``` -------------------------------- ### Run act with Schedule Event Source: https://nektosact.com/print.html This snippet shows how to execute workflows that are scheduled to run. ```bash __ act schedule ``` -------------------------------- ### Run Latest act Version with Nix Source: https://nektosact.com/installation/nix.html Execute the most recent version of 'act' directly using the Nix command. ```bash nix run nixpkgs#act ``` -------------------------------- ### Running Self-Hosted Runners Source: https://nektosact.com/usage/runners.html Use the `-P` option to specify that a runner should be treated as self-hosted. This is useful for platforms that `act` does not directly support via Docker. ```bash act -P ubuntu-latest=-self-hosted act -P windows-latest=-self-hosted act -P macos-latest=-self-hosted ``` -------------------------------- ### Provide Repository Variables Interactively Source: https://nektosact.com/print.html Repository variables, accessible via `${{ vars.VARIABLE }}`, can be provided using the '--var' flag for individual variables or '--var-file' to load them from a file. ```bash __ act --var VARIABLE=some-value ``` ```bash __ act --var-file my.variables ``` -------------------------------- ### Specifying Custom Docker Images for Runners Source: https://nektosact.com/print.html Use the `-P` option to map a platform to a specific Docker image. This allows you to use custom or pre-configured environments for your workflows. ```bash act -P = ``` ```bash act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 ``` ```bash act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:16-buster-slim ``` -------------------------------- ### Checkout Action with Path Configuration Source: https://nektosact.com/known_issues/module_not_found.html This snippet demonstrates how to use 'actions/checkout@v2' with a specific path. The 'path' value must match the repository name to avoid MODULE_NOT_FOUND errors when testing locally. ```yaml steps: - name: Checkout uses: actions/checkout@v2 with: path: "my-action" ``` -------------------------------- ### Run Workflow for Push Event Source: https://nektosact.com/usage/index.html Executes all workflows triggered by the 'push' event. This is the default behavior if no event is specified. ```bash act push ``` -------------------------------- ### Simulate Push Event with Tag Source: https://nektosact.com/usage/index.html Provides the 'ref' property to simulate a 'push' event with a tag, making the tag accessible via `${{ github.event.ref }}`. ```json { "ref": "refs/tags/this-is-a-tag" } ``` -------------------------------- ### Load Secrets from File Source: https://nektosact.com/usage/index.html Loads secrets from a file named 'my.secrets'. The file format is compatible with '.env' files. ```bash act --secret-file my.secrets ``` -------------------------------- ### Provide GITHUB_TOKEN using GitHub CLI Source: https://nektosact.com/usage/index.html Automatically sets the 'GITHUB_TOKEN' secret by fetching the token from the GitHub CLI. This simplifies authentication for act. ```bash act -s GITHUB_TOKEN="$(gh auth token)" ``` -------------------------------- ### Conditional Job Execution with GitHub Context Source: https://nektosact.com/usage/index.html Shows how to use the GitHub event context for conditional logic in jobs, specifically skipping during local testing with Act. ```yaml __ on: push jobs: deploy: if: ${{ !github.event.act }} # skip during local actions testing runs-on: ubuntu-latest steps: - run: exit 0 ``` -------------------------------- ### Specifying Custom Images for Multiple Platforms Source: https://nektosact.com/usage/runners.html When a workflow uses multiple platforms, specify custom Docker images for each platform to ensure consistent behavior. ```bash act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:16-buster-slim ``` -------------------------------- ### Specify Workflow Directory Source: https://nektosact.com/usage/index.html Runs all workflows within the specified directory '.github/workflows/'. This overrides the default behavior of searching in '.github/workflows'. ```bash act -W '.github/workflows/' ``` -------------------------------- ### Environment Variables in .env/.secrets Source: https://nektosact.com/usage/index.html Demonstrates the format for environment variables in .env and .secrets files, compatible with the dotenv gem format. ```shell __ export MY_ENV='value' PRIV_KEY="---\nrandom text\n...---" JSON="{\"name\": \"value\"}" SOME_VAR=SOME_VALUE ``` -------------------------------- ### Running Act with Matrix Subset - Multiple Dimensions Source: https://nektosact.com/usage/index.html Command to run a workflow with a specific subset of matrix configurations using the --matrix flag for multiple dimensions. ```shell act push --matrix node:10 --matrix os:macos-latest ``` -------------------------------- ### Simulate Pull Request Event with Properties Source: https://nektosact.com/usage/index.html Provides necessary properties like 'head_ref' and 'base_ref' to partially simulate a 'pull_request' event for workflow testing. ```json { "pull_request": { "head": { "ref": "sample-head-ref" }, "base": { "ref": "sample-base-ref" } } } ``` -------------------------------- ### Export DOCKER_HOST for Podman with act Source: https://nektosact.com/usage/custom_engine.html Alternatively, export the DOCKER_HOST environment variable before running act to direct it to use Podman. Ensure the Podman socket is accessible. ```bash export DOCKER_HOST='unix:///var/run/podman/podman.sock' act # ... ``` -------------------------------- ### Running Act with Custom Event JSON Source: https://nektosact.com/usage/index.html Command to run Act with a specific event JSON file, overriding default behavior. ```shell __ act -e event.json ``` -------------------------------- ### Running Act with a Custom Event Payload Source: https://nektosact.com/print.html Execute Act with a specified event payload file using the '-e' flag. ```bash act -e event.json ``` -------------------------------- ### List Workflows for an Event Source: https://nektosact.com/usage/index.html Lists all workflows associated with the 'pull_request' event. Use the -l or --list flags for this purpose. ```bash act -l pull_request ``` -------------------------------- ### Provide Secrets Interactively or from File Source: https://nektosact.com/print.html Secrets can be provided using the '-s' flag for individual secrets or '--secret-file' to load them from a file. Using '-s SECRET_NAME' without a value prompts for secure input. ```bash __ act -s MY_SECRET=some-value ``` ```bash __ act -s MY_SECRET ``` ```bash __ act --secret-file my.secrets ``` -------------------------------- ### Running Act with Matrix Subset - Single Dimension Source: https://nektosact.com/usage/index.html Command to run a workflow with a specific subset of matrix configurations using the --matrix flag for a single dimension. ```shell act push --matrix node:8 ``` -------------------------------- ### Run act with Pull Request Event Source: https://nektosact.com/print.html This snippet demonstrates how to run workflows specifically triggered by a 'pull_request' event. ```bash __ act pull_request ``` -------------------------------- ### Run Specific Jobs by Name Source: https://nektosact.com/print.html Use the '-j' or '--jobs' flag to execute jobs with a specific name, such as 'test', across all workflows triggered by the 'push' event. ```bash __ act -j 'test' ``` -------------------------------- ### Run Workflow for Pull Request Event Source: https://nektosact.com/usage/index.html Executes all workflows triggered by the 'pull_request' event. ```bash act pull_request ``` -------------------------------- ### Use Podman with act via sh Source: https://nektosact.com/usage/custom_engine.html Configure act to use Podman by setting the DOCKER_HOST environment variable to the Podman socket path. This is useful when Podman is your preferred container runtime. ```bash DOCKER_HOST='unix:///var/run/podman/podman.sock' act # ... ``` -------------------------------- ### Run Workflow for Schedule Event Source: https://nektosact.com/usage/index.html Executes all workflows triggered by the 'schedule' event. ```bash act schedule ``` -------------------------------- ### Local Action Test Configuration Source: https://nektosact.com/known_issues/module_not_found.html This snippet shows how to configure a local action test within a workflow. Ensure this is used when developing actions locally. ```yaml name: test action locally uses: ./ ``` -------------------------------- ### Environment Variables in .env/.secrets Source: https://nektosact.com/print.html Load environment variables using the dotenv format, similar to Ruby's dotenv gem. Supports basic strings, multi-line strings, and JSON. ```bash export MY_ENV='value' PRIV_KEY="---\nrandom text\n...---" JSON="{\"name\": \"value\"}" SOME_VAR=SOME_VALUE ``` -------------------------------- ### Specifying a Custom Docker Image for a Runner Source: https://nektosact.com/usage/runners.html Use the `-P` option to override the default Docker image for a specific runner platform. This allows you to use custom environments. ```bash act -P = ``` -------------------------------- ### Run Specific Job by Name Source: https://nektosact.com/usage/index.html Executes all jobs named 'test' across all workflows triggered by the 'push' event. Use the -j or --job flag to specify job names. ```bash act -j 'test' ``` -------------------------------- ### Skipping Steps with ACT Environment Variable Source: https://nektosact.com/usage/index.html Illustrates using the ACT environment variable to conditionally skip specific steps within a job, useful for preventing actions like Slack notifications during local runs. ```yaml __ - name: Some step if: ${{ !env.ACT }} run: | ... ``` -------------------------------- ### Set DOCKER_CERT_PATH for TLS Source: https://nektosact.com/missing_functionality/docker_context.html If your Docker host requires client certificates for connection, use this snippet to set the `DOCKER_CERT_PATH` environment variable. This ensures `act` can connect securely to the Docker host. ```bash export DOCKER_CERT_PATH=$(docker context inspect --format '{{.Storage.TLSPath}}')/docker ``` -------------------------------- ### Enabling Offline Mode Source: https://nektosact.com/usage/runners.html Use the `--action-offline-mode` flag to enable offline mode, which prevents `act` from attempting to download actions from the network. ```bash act --action-offline-mode ``` -------------------------------- ### Specify Single Workflow File Source: https://nektosact.com/usage/index.html Runs all jobs within a specific workflow file, '.github/workflows/checks.yml'. This targets a single workflow for execution. ```bash act -W '.github/workflows/checks.yml' ``` -------------------------------- ### Set DOCKER_HOST from Docker Context Source: https://nektosact.com/missing_functionality/docker_context.html Use this snippet to set the `DOCKER_HOST` environment variable to the host specified in your current Docker context. This is necessary because `act` does not automatically respect `docker context` settings. ```bash export DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}') ``` -------------------------------- ### Run act with Push Event Source: https://nektosact.com/print.html Running 'act' without an event name defaults to the 'push' event. This snippet shows how to explicitly run workflows triggered by a 'push' event. ```bash __ act push ``` -------------------------------- ### Use Environment Variable for Secret Source: https://nektosact.com/usage/index.html Uses the value of the environment variable 'MY_SECRET' as the secret. If not found, prompts the user. ```bash act -s MY_SECRET ``` -------------------------------- ### Act Offline Mode via Command Line Source: https://nektosact.com/usage/index.html Enables Act's offline mode using the --action-offline-mode flag, which stops pulling existing images and allows working offline if previously run online. ```shell act --action-offline-mode ``` -------------------------------- ### Provide GITHUB_TOKEN Secret Source: https://nektosact.com/print.html The GITHUB_TOKEN secret is automatically provided by GitHub. If your workflow requires it, pass it to 'act' using the '-s' flag. Secure input can be used by omitting the value. ```bash __ act -s GITHUB_TOKEN=[insert token or leave blank and omit equals for secure input] ``` -------------------------------- ### Provide GITHUB_TOKEN Secret Source: https://nektosact.com/usage/index.html Sets the 'GITHUB_TOKEN' secret. If the value is omitted, act will prompt for secure input. This is crucial for workflows requiring authentication. ```bash act -s GITHUB_TOKEN=[insert token or leave blank and omit equals for secure input] ``` -------------------------------- ### Provide Secret Interactively Source: https://nektosact.com/usage/index.html Sets a secret named 'MY_SECRET' to 'some-value'. This is one method for providing secrets to act. ```bash act -s MY_SECRET=some-value ``` -------------------------------- ### Provide Repository Variable Interactively Source: https://nektosact.com/usage/index.html Sets a repository variable named 'VARIABLE' to 'some-value' for use within workflows. ```bash act --var VARIABLE=some-value ``` -------------------------------- ### Triggering Workflow Dispatch with Event Payload Source: https://nektosact.com/usage/index.html Command to trigger a workflow_dispatch event using Act, providing a JSON payload file. ```shell act workflow_dispatch -e payload.json ``` -------------------------------- ### Act Offline Mode via .actrc File Source: https://nektosact.com/usage/index.html Configures Act's offline mode by adding the --action-offline-mode flag to the .actrc file in the current working directory. ```shell --action-offline-mode ``` -------------------------------- ### Enabling Act Offline Mode Source: https://nektosact.com/print.html Activate Act's offline mode to speed up execution by using cached actions and images, and to work without an internet connection after an initial online run. ```bash act --action-offline-mode ``` -------------------------------- ### Use remote Docker engine with act via SSH Source: https://nektosact.com/usage/custom_engine.html Connect act to a remote Docker engine over SSH by specifying the SSH connection string in the DOCKER_HOST variable. This allows running workflows on a different machine. ```bash DOCKER_HOST='ssh://user@host' act # ... ``` -------------------------------- ### Disabling Docker Image Pulling Source: https://nektosact.com/usage/runners.html Set the `--pull=false` flag to prevent `act` from pulling Docker images every time it executes. This is useful if you have local images and want to speed up execution. ```bash act --pull=false ``` -------------------------------- ### Use remote Docker engine with act via SSH in PowerShell Source: https://nektosact.com/usage/custom_engine.html Configure act to use a remote Docker engine via SSH within a PowerShell environment by setting the DOCKER_HOST environment variable. This is the PowerShell equivalent for remote connections. ```powershell $env:DOCKER_HOST = 'ssh://user@host' act # ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.