Skip to content
Latchkey

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 bundle with 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 --version

Gotchas

  • If a formula is already in the image, brew install reports it as installed; use brew list <formula> || brew install <formula> to stay idempotent.
  • Pin major tools to a version with brew install <formula>@<ver> when reproducibility matters.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →