The examples below cover the most common ways to integrate Setup Mago into a GitHub Actions workflow. Every snippet is complete and ready to paste — adjust theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nhedger/setup-mago/llms.txt
Use this file to discover all available pages before exploring further.
mago command at the end to match whatever subcommand your project uses (lint, format, check, etc.).
Automatic version detection
The simplest possible setup: omit theversion input entirely and let the action read the Mago version from your composer.lock. This is the recommended approach for most projects because the installed CLI version always matches the version pinned in your lockfile.
Latest version
Explicitly request the newest stable release of the Mago CLI. Use this when you always want the latest features and are not pinning a specific version in your Composer files.version: latest bypasses Composer file detection entirely. The action fetches all published stable releases from GitHub and installs the highest one.Specific version
Pin the action to a known Mago release. This is useful in security-sensitive pipelines or when you need to reproduce an exact CI environment regardless of what is incomposer.lock.
Monorepo — pointing at a subdirectory
In a monorepo where the PHP project lives in a subdirectory, useworking-directory to tell the action where to find composer.lock and composer.json. The Mago binary is still added to the PATH globally, so the run step can invoke mago from any directory.
working-directory only affects where the action looks for Composer files during version detection. It does not change the working directory of subsequent run steps — set working-directory on those steps separately if needed.Matrix build across operating systems
Run Mago on Linux, macOS, and Windows in parallel to verify your code passes on every platform that GitHub Actions supports. Setup Mago automatically downloads the correct binary for each runner.Custom GitHub token
If your workflow hits GitHub API rate limits — which can happen in large organizations with many concurrent CI runs — supply a Personal Access Token (PAT) via thetoken input. Store the PAT as a repository or organization secret.
The default value of
token is ${{ github.token }}, so referencing ${{ secrets.GITHUB_TOKEN }} explicitly is equivalent and requires no additional setup. A custom PAT is only necessary when the default token’s rate limit is insufficient.