How to Install a Tool With Homebrew in GitHub Actions
Homebrew is preinstalled on macOS runners, so installing a tool is one brew install call with auto-update turned off.
Run brew install <formula> directly. Set HOMEBREW_NO_AUTO_UPDATE=1 so brew skips the slow self-update, and use brew bundle when you need several tools from a Brewfile.
Steps
- Disable auto-update with
HOMEBREW_NO_AUTO_UPDATE=1. - Run
brew install <formula>for a single tool. - Use
brew bundlewith a Brewfile for several tools at once.
Workflow
.github/workflows/ci.yml
jobs:
lint:
runs-on: macos-latest
env:
HOMEBREW_NO_AUTO_UPDATE: '1'
steps:
- uses: actions/checkout@v4
- run: brew install swiftlint xcbeautify
- run: swiftlint version && xcbeautify --versionGotchas
- If a formula is already in the image,
brew installreports it as installed; usebrew list <formula> || brew install <formula>to stay idempotent. - Pin major tools to a version with
brew install <formula>@<ver>when reproducibility matters.