### Install act from Latest Commit using Homebrew Source: https://github.com/nektos/act-docs/blob/main/src/installation/homebrew.md Installs the 'act' tool directly from the latest commit in the repository. This requires a compiler to be installed, and Homebrew will guide you if it's missing. Use this for the most up-to-date version. ```shell brew install act --HEAD ``` -------------------------------- ### Configuration File Example Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Demonstrates the format of an .actrc configuration file, specifying arguments like container architecture and offline mode. ```shell --container-architecture=linux/amd64 --action-offline-mode ``` -------------------------------- ### Install act using Bash Script Source: https://github.com/nektos/act-docs/blob/main/src/installation/index.md Installs a pre-built act executable on any system with bash. This script fetches the latest release and installs it system-wide. It cannot install non-released versions. ```shell curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash ``` -------------------------------- ### Passing Inputs to Manually Triggered Workflows Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Provides examples of how to pass inputs to workflows triggered manually using the `workflow_dispatch` event. Demonstrates passing inputs via command-line flags, input files, and JSON payloads. ```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 }}!" ``` ```bash act --input NAME=some-value ``` ```bash act --input-file my.input ``` ```json { "inputs": { "NAME": "Manual Workflow", "SOME_VALUE": "ABC" } } ``` ```bash act workflow_dispatch -e payload.json ``` -------------------------------- ### Install act with Nix Source: https://github.com/nektos/act-docs/blob/main/src/installation/nix.md Installs the 'act' tool globally using Nix. This command adds the 'act' package to your Nix environment. ```sh nix-env -iA nixpkgs.act ``` -------------------------------- ### Install ACT using WinGet Source: https://github.com/nektos/act-docs/blob/main/src/installation/winget.md This command installs the ACT (Actions Runner Controller) package from the WinGet repository. Ensure you have WinGet installed and configured on your Windows system. ```shell winget install nektos.act ``` -------------------------------- ### Install act using Homebrew Source: https://github.com/nektos/act-docs/blob/main/src/installation/homebrew.md Installs the 'act' tool using the standard Homebrew package manager. This is the recommended method for most users. ```shell brew install act ``` -------------------------------- ### Run act with Nix command Source: https://github.com/nektos/act-docs/blob/main/src/installation/nix.md Executes the 'act' tool directly using the latest Nix command. This method allows running the tool without any prior installation. ```sh nix run nixpkgs#act ``` -------------------------------- ### Install act with Scoop Source: https://github.com/nektos/act-docs/blob/main/src/installation/scoop.md Installs the 'act' command-line tool on Windows using the Scoop package manager. Scoop is a command-line installer for Windows. ```shell scoop install act ``` -------------------------------- ### Run act commands using GitHub CLI Source: https://github.com/nektos/act-docs/blob/main/src/installation/gh.md Demonstrates how to execute 'act' commands after installation as a GitHub CLI extension. These commands allow you to trigger workflows like 'push' or specify event types like 'pull_request'. ```sh gh act push gh act -l pull_request ``` -------------------------------- ### Specifying Matrix Configurations with act Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Explains how to use the `--matrix` flag with act to selectively run specific matrix configurations defined in a workflow. Shows examples of filtering by a single matrix dimension and by multiple dimensions, and discusses precedence rules with 'exclude'. ```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 ``` ```bash act push --matrix node:8 ``` ```bash act push --matrix node:10 --matrix os:macos-latest ``` -------------------------------- ### Environment File Structure (.env/.secrets) Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Illustrates the format for .env and .secrets files used by the godotenv library, which is compatible with Ruby's dotenv gem. Shows examples of exporting variables, handling multi-line strings, and basic key-value pairs. ```shell export MY_ENV='value' PRIV_KEY="---\nrandom text\n...---" JSON="{\"name\": \"value\"}" SOME_VAR=SOME_VALUE ``` -------------------------------- ### Install Act using Pacman Source: https://github.com/nektos/act-docs/blob/main/src/installation/arch.md This command installs the 'act' package on Arch Linux. It updates the system package list and then installs the 'act' tool. Ensure your system is up-to-date before installing new packages. ```shell pacman -Syu act ``` -------------------------------- ### Run act with nix-shell Source: https://github.com/nektos/act-docs/blob/main/src/installation/nix.md Runs the 'act' tool within a temporary Nix shell environment. This is useful for trying out the tool without a global installation. ```sh nix-shell -p act ``` -------------------------------- ### Install act as GitHub CLI extension Source: https://github.com/nektos/act-docs/blob/main/src/installation/gh.md Installs the 'act' tool as an extension for the GitHub CLI. This allows you to run GitHub Actions workflows directly from your terminal. ```sh gh extension install https://github.com/nektos/gh-act ``` -------------------------------- ### Build act from Source Source: https://github.com/nektos/act-docs/blob/main/src/installation/index.md Instructions for building the act executable from its source code. Requires Go toolchain version 1.18 or higher. Provides two methods: a simple 'make build' and a more detailed go build command with versioning. ```shell git clone https://github.com/nektos/act.git cd act/ make build ``` ```go go build -ldflags "-X main.version=$(git describe --tags --dirty --always | sed -e 's/^v//')" -o dist/local/act main.go ``` -------------------------------- ### Install act-cli with Chocolatey Source: https://github.com/nektos/act-docs/blob/main/src/installation/chocolatey.md Installs the act-cli package using the Chocolatey package manager for Windows. Ensure Chocolatey is installed and configured before running this command. ```shell choco install act-cli ``` -------------------------------- ### Install act-cli via COPR on Fedora Source: https://github.com/nektos/act-docs/blob/main/src/installation/copr.md Enables the COPR repository for act-cli and installs the act-cli package using dnf. ```shell dnf copr enable goncalossilva/act dnf install act-cli ``` -------------------------------- ### Skipping Jobs Locally with act Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Explains how to prevent jobs from running during local testing with act by using a condition based on the 'act' event property. Shows a YAML example for a job and the corresponding event.json file to trigger it. ```yaml on: push jobs: deploy: if: ${{ !github.event.act }} # skip during local actions testing runs-on: ubuntu-latest steps: - run: exit 0 ``` -------------------------------- ### Install act using MacPorts Source: https://github.com/nektos/act-docs/blob/main/src/installation/macports.md This command installs the 'act' tool on macOS using the MacPorts package manager. Ensure you have MacPorts installed and updated before running this command. ```shell sudo port install act ``` -------------------------------- ### Running Act with Push Event Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Executes all workflows triggered by the 'push' event. This is the default event if none is specified. ```shell act push ``` -------------------------------- ### Enable Artifact Server Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Enables the artifact server for Act by specifying a path for storing artifacts. This allows for uploading and downloading artifacts within the current workflow run using actions like `actions/upload-artifact` and `actions/download-artifact`. ```sh act --artifact-server-path $PWD/.artifacts ``` -------------------------------- ### Specifying Workflow Directory Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Runs all jobs in all workflows located within a specified directory, such as '.github/workflows/'. ```shell act -W '.github/workflows/' ``` -------------------------------- ### Running Workflows with Self-Hosted Runners Source: https://github.com/nektos/act-docs/blob/main/src/usage/runners.md Examples demonstrating how to configure 'act' to use self-hosted runners for different platforms (Ubuntu, Windows, macOS). This is useful when you want to run workflows directly on your host system instead of using Docker containers. ```sh act -P ubuntu-latest=-self-hosted act -P windows-latest=-self-hosted act -P macos-latest=-self-hosted ``` -------------------------------- ### Running Act with Schedule Event Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Executes all workflows triggered by the 'schedule' event. ```shell act schedule ``` -------------------------------- ### Using GITHUB_TOKEN with act Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Demonstrates how to provide the GITHUB_TOKEN secret to act for workflows that require it. It shows direct token insertion and using the GitHub CLI for automatic token retrieval. Includes a warning about token exposure in shell history. ```bash act -s GITHUB_TOKEN=[insert token or leave blank and omit equals for secure input] ``` ```bash act -s GITHUB_TOKEN="$(gh auth token)" ``` -------------------------------- ### Running Act with Pull Request Event Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Executes all workflows triggered by the 'pull_request' event. ```shell act pull_request ``` -------------------------------- ### Simulating Push Event with Tag using Event File Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Provides a JSON payload to simulate a 'push' event with a tag, making the tag reference accessible within workflows. ```json { "ref": "refs/tags/this-is-a-tag" } ``` -------------------------------- ### Running Specific Jobs Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Executes all jobs named 'test' across all workflows triggered by the default 'push' event. ```shell act -j 'test' ``` -------------------------------- ### Listing Workflows for an Event Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Lists all workflows associated with a specific event, such as 'pull_request'. ```shell act -l pull_request ``` -------------------------------- ### Loading Variables from File Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Loads repository variables from a file named 'my.variables', following a format similar to .env files. ```shell act --var-file my.variables ``` -------------------------------- ### Specifying Alternative Runner Images Source: https://github.com/nektos/act-docs/blob/main/src/usage/runners.md Demonstrates how to use the '-P' option with 'act' to specify custom Docker images for runners. This allows you to use environments that more closely match GitHub's official runners or have specific toolchains installed. ```sh act -P = ``` ```sh act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 ``` ```sh act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 -P ubuntu-latest=ubuntu:latest -P ubuntu-16.04=node:16-buster-slim ``` -------------------------------- ### Specifying Exact Workflow File Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Runs all jobs within a specific workflow file, like '.github/workflows/checks.yml'. ```shell act -W '.github/workflows/checks.yml' ``` -------------------------------- ### Loading Secrets from File Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Loads secrets from a file named 'my.secrets', using a format similar to .env files. ```shell act --secret-file my.secrets ``` -------------------------------- ### Setting Secrets Interactively Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Sets a secret named 'MY_SECRET' to the value 'some-value'. ```shell act -s MY_SECRET=some-value ``` -------------------------------- ### Setting Variables Interactively Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Sets a repository variable named 'VARIABLE' to the value 'some-value' for use within workflows. ```shell act --var VARIABLE=some-value ``` -------------------------------- ### Simulating Pull Request Event with Event File Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Provides a JSON payload to simulate a 'pull_request' event, including head and base references, which can be accessed within workflows. ```json { "pull_request": { "head": { "ref": "sample-head-ref" }, "base": { "ref": "sample-base-ref" } } } ``` -------------------------------- ### Using Environment Variables for Secrets Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Uses the value of the 'MY_SECRET' environment variable as a secret. If not set, prompts the user securely. ```shell act -s MY_SECRET ``` -------------------------------- ### Skipping Steps Locally with act Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Details how to conditionally skip specific steps within a GitHub Actions workflow when running locally with act. It utilizes the ACT environment variable, which act sets automatically. ```yaml - name: Some step if: ${{ !env.ACT }} run: | ... ``` -------------------------------- ### Skipping Jobs Locally with act (event.json) Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Provides the JSON content for an event file used with the `act -e` command to control job execution during local testing. This specific JSON payload ensures that jobs with the condition `!github.event.act` will run. ```json { "act": true } ``` -------------------------------- ### Enable Action Offline Mode Source: https://github.com/nektos/act-docs/blob/main/src/usage/index.md Enables offline mode for Act, preventing image pulls and allowing cached actions to be used even without a GitHub connection. This improves performance and resilience against network issues. ```sh act --action-offline-mode ``` ```sh --action-offline-mode ``` -------------------------------- ### act Project Overview Source: https://github.com/nektos/act-docs/blob/main/src/introduction.md The act project is written in Go and aims to provide a seamless local development experience for GitHub Actions. It interacts with the Docker API to manage containerized execution of workflows. ```go // Project written in Go // Uses Docker API for container management ``` -------------------------------- ### Running GitHub Actions Locally Source: https://github.com/nektos/act-docs/blob/main/src/introduction.md This command initiates the execution of GitHub Actions workflows defined in the .github/workflows/ directory. It leverages Docker to build or pull necessary images and run containers for each action, replicating the GitHub Actions execution environment. ```bash act ``` -------------------------------- ### Action Metadata Configuration Options Source: https://github.com/nektos/act-docs/blob/main/src/support_matrix.md Defines the structure and supported options for custom GitHub Actions, including metadata, inputs, outputs, and execution logic. ```APIDOC Action: name: string description: string inputs: object outputs: object runs: using: string (docker | node12 | node16 | composite) image: string (for docker) main: string (for nodejs) args: array[string] (for docker/nodejs) steps: array[object] (for composite) ``` -------------------------------- ### Using Podman with act Source: https://github.com/nektos/act-docs/blob/main/src/usage/custom_engine.md Demonstrates how to use Podman as the container engine with act by setting the DOCKER_HOST environment variable to the Podman socket path. This allows act to interact with containers managed by Podman. ```shell DOCKER_HOST='unix:///var/run/podman/podman.sock' act # ... export DOCKER_HOST='unix:///var/run/podman/podman.sock' act # ... ``` -------------------------------- ### Configure GitHub Enterprise Instance Source: https://github.com/nektos/act-docs/blob/main/src/usage/github_enterprise.md This snippet shows how to configure Act to use a private GitHub Enterprise server by setting the `--github-instance` flag. It also mentions the use of `GITHUB_TOKEN` for authentication. ```bash act --github-instance github.company.com # Ensure GITHUB_TOKEN is set for authentication ``` -------------------------------- ### Workflow Configuration Options Source: https://github.com/nektos/act-docs/blob/main/src/support_matrix.md Defines the structure and supported options for GitHub Actions workflows, including triggers, jobs, steps, and environment configurations. ```APIDOC Workflow: name: string on: event_name.types: array[string] pull_request | pull_request_target: branches: array[string] branches-ignore: array[string] push: branches: array[string] tags: array[string] branches-ignore: array[string] tags-ignore: array[string] schedule: array[object] workflow_call: object workflow_run: branches: array[string] branches-ignore: array[string] workflow_dispatch: object permissions: object env: object defaults: run: shell: string working-directory: string concurrency: object jobs: object : name: string permissions: object needs: array[string] if: string runs-on: string environment: object concurrency: object outputs: object env: object defaults: run: shell: string working-directory: string steps: array[object] id: string if: string name: string uses: string (composite actions) run: string shell: string with: object args: string entrypoint: string env: object continue-on-error: boolean timeout-minutes: number timeout-minutes: number strategy: matrix: object fail-fast: boolean (won't actually fail fast) max-parallel: number (incomplete support [Issue #150](https://github.com/nektos/act/issues/158)) continue-on-error: boolean container: image: string credentials: object env: object ports: array[string] volumes: array[string] options: object (supports only --hostname) services: object ([PR #775](https://github.com/nektos/act/pull/775)) : image: string credentials: object env: object ports: array[string] volumes: array[string] options: object uses: string with: object secrets: object ``` -------------------------------- ### Managing Docker Image Pulls and Offline Mode Source: https://github.com/nektos/act-docs/blob/main/src/usage/runners.md Shows how to control Docker image pulling behavior in 'act'. Setting '--pull=false' uses local images, while '--action-offline-mode' enables offline execution, which can be useful in environments with limited network access. ```sh act --pull=false ``` ```sh act --action-offline-mode ``` -------------------------------- ### Using Remote Docker Engine with act via SSH Source: https://github.com/nektos/act-docs/blob/main/src/usage/custom_engine.md Shows how to connect act to a remote Docker engine using SSH by specifying the SSH connection string in the DOCKER_HOST environment variable. This enables running act workflows on a remote Docker host. ```shell DOCKER_HOST='ssh://user@host' act # ... ``` -------------------------------- ### Correcting actions/checkout path for local actions Source: https://github.com/nektos/act-docs/blob/main/src/known_issues/module_not_found.md This snippet demonstrates the correct configuration for the `actions/checkout@v2` step when using a local action path. It ensures the `path` parameter matches the repository name to prevent `MODULE_NOT_FOUND` errors. ```yaml steps: - name: Checkout uses: actions/checkout@v2 with: path: "my-action" ``` -------------------------------- ### Set DOCKER_CERT_PATH for TLS Context Source: https://github.com/nektos/act-docs/blob/main/src/missing_functionality/docker_context.md This snippet shows how to set the DOCKER_CERT_PATH environment variable when the Docker context requires client certificates for TLS authentication. It inspects the current Docker context to find the TLS path and appends '/docker' to it. ```bash export DOCKER_CERT_PATH=$(docker context inspect --format '{{.Storage.TLSPath}}')/docker ``` -------------------------------- ### Set DOCKER_HOST from Docker Context Source: https://github.com/nektos/act-docs/blob/main/src/missing_functionality/docker_context.md This snippet demonstrates how to set the DOCKER_HOST environment variable to match the current Docker context's host. This is a workaround for act not respecting Docker contexts directly. It inspects the current Docker context and extracts the host endpoint. ```bash export DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}') ``` -------------------------------- ### Using Remote Docker Engine with act via SSH in PowerShell Source: https://github.com/nektos/act-docs/blob/main/src/usage/custom_engine.md Illustrates how to configure act to use a remote Docker engine over SSH within a PowerShell environment. The DOCKER_HOST environment variable is set using PowerShell syntax. ```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.