Homebrew Actions

repository·main·Indexed 41 days ago

https://github.com/homebrew/actions

A collection of specialized GitHub Actions used by the Homebrew project to automate workflows. Includes tools for updating packages (bump-packages, bump-formulae), managing commits (api-commit-and-push, check-commit-format), caching the Homebrew prefix (cache-homebrew-prefix), and automating GitHub issues and pull requests (create-or-update-issue, create-pull-request).

Tokens
15.1K
Snippets
41
Records
63
Agent score
51%

What's inside Homebrew Actions

  1. Use Homebrew's GitHub Actions

    main
    This repository contains multiple independent GitHub Actions. Each subdirectory (excluding node_modules) represents a separate Action. To use a specific Action, navigate to its corresponding subdirectory in the repository to find its implementation and usage details.
  2. Use Bundler cache with Setup Ruby

    main

    To speed up dependency installation, enable bundler-cache: true.

    When enabled, the action:

    1. Caches vendor/bundle using actions/cache.
    2. Configures Bundler to install gems to vendor/bundle.
    3. Automatically runs bundle check and bundle install --jobs 4 --retry 3 only if necessary.
    4. Uses Gemfile.lock (or Gemfile if lock is missing) for cache hashing.
    5. Includes the Ruby version, portable Ruby mode, and Ruby prefix in the cache key to ensure cache integrity.
    - name: Set up Ruby with Bundler cache
      uses: Homebrew/actions/setup-ruby@1f8e202ffddf94def7f42f6fa3a482e821489f9c
      with:
        setup-homebrew: true
        bundler-cache: true
  3. Configure Homebrew repository checkout behavior

    main

    The action manages the checkout of homebrew/brew based on the type of repository being tested:

    • Non-brew and non-tap repositories: homebrew/brew is checked out at the latest stable tag.
    • brew and tap repositories: homebrew/brew stays on the main branch by default. To use a stable tag for these repository types, set stable: true explicitly in the action configuration.
  4. Use the Label pull requests GitHub Action

    main

    The label-pull-requests action automatically labels pull requests based on defined criteria. It evaluates the files changed in the PR, the content of those files, and the PR body. Crucially, it will also remove labels from a pull request that no longer satisfy the defined criteria.

    You can provide the labeling definitions (def) using either a JSON array or a YAML list. Both formats require a token (typically a GitHub API token) to perform the labeling operations.

    - name: Label PR
      uses: Homebrew/actions/label-pull-requests@1f8e202ffddf94def7f42f6fa3a482e821489f9c
      with:
        token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}
        def: |
          - label: example-label
            path: Formula/.+
  5. Use the Failures summary and bottle result GitHub Action

    main

    The failures-summary-and-bottle-result action dumps logs generated by brew test-bot. It is typically used in a workflow step with if: always() to ensure that failure summaries are captured even if previous steps in the job failed.

    Configuration Options

    OptionDescription
    workdirThe working directory where the action should run. Defaults to ${{ github.workspace }}.
    result_pathThe path to the file containing the results (e.g., bottles/steps_output.txt).
    step_nameThe name displayed for the step in the GitHub Actions UI.
    collapseWhether to collapse the output in the GitHub Actions summary. Set to 'true' to enable.
    - name: Failures summary and bottle result
      if: always()
      uses: Homebrew/actions/failures-summary-and-bottle-result@1f8e202ffddf94def7f42f6fa3a482e821489f9c # 2026.07.10.1
      with:
        workdir: ${{ github.workspace }}
        result_path: bottles/steps_output.txt
        step_name: 'Build failure summary on ${{ matrix.runner }}'
        collapse: 'true'
  6. Set up Ruby using the Setup Ruby GitHub Action

    main

    The setup-ruby action installs and configures Ruby using Homebrew. It is compatible with ubuntu and macos runners (the latter requires Homebrew to be present).

    By default, the action installs the Homebrew ruby formula and adds it to the PATH. You can also choose to use Homebrew's portable Ruby, which is the same Ruby that Homebrew itself uses (brew ruby).

    - name: Set up Ruby
      uses: Homebrew/actions/setup-ruby@1f8e202ffddf94def7f42f6fa3a482e821489f9c
  7. Use the API commit and push GitHub Action

    main

    The api-commit-and-push action commits and pushes changes to a repository using the GitHub API instead of the standard git CLI. This is specifically useful for GitHub Apps that must use the API to ensure commits are properly signed.

    To use this action, you must first obtain a token (e.g., via actions/create-github-app-token) and then provide that token, a commit message, and a target branch to the action.

    - uses: actions/create-github-app-token@v3
      id: app-token
      with:
        app-id: ${{ vars.APP_ID }}
        private-key: ${{ secrets.PRIVATE_KEY }}
    
    - run: git add some/file.txt
    
    - uses: Homebrew/actions/api-commit-and-push@1f8e202ffddf94def7f42f6fa3a482e821489f9c # 2026.07.10.1
      with:
        message: Update generated files
        branch: some-branch
        token: ${{ steps.app-token.outputs.token }}
  8. Use the Bump packages GitHub Action

    main

    The bump-packages action wraps brew bump to automate the process of updating outdated packages. It utilizes brew livecheck internally to identify outdated packages and can run on ubuntu (for formulae only) or macos (for formulae and casks).

    If no outdated packages are detected, the action exits without performing any operations.

    Important Security Note: You must use a Personal Access Token with the public_repo scope for the token input. Do not use the default GITHUB_TOKEN, as brew bump needs to create forks of tap repositories and open pull requests, which the default token cannot do.

    - name: Bump packages
      uses: Homebrew/actions/bump-packages@1f8e202ffddf94def7f42f6fa3a482e821489f9c # 2026.07.10.1
      with:
        token: ${{secrets.TOKEN}}
        formulae: >
          FORMULA-1
          FORMULA-2
        casks: >
          CASK-1
          CASK-2
        fork: false
  9. Set up the Limit pull requests GitHub Action

    main

    The limit-pull-requests action restricts the number of open pull requests a specific user can have in a repository.

    Prerequisites

    • Tools: The runner must have GitHub CLI (gh) and jq installed.
    • Workflow Trigger: This action must be used in a pull_request_target workflow to ensure it has the necessary permissions to interact with pull requests.
    • Permissions: The workflow requires the following GitHub permissions:
      • contents: read
      • pull-requests: write
    permissions:
      contents: read
      pull-requests: write
  10. Cache Homebrew Bundler RubyGems

    main

    The setup-homebrew action provides outputs that allow you to cache RubyGems installed by Homebrew developer commands (such as brew style).

    To implement caching, use the actions/cache@v5 action with the following outputs from the setup-homebrew step:

    • gems-path: The path to the installed gems.
    • gems-hash: A hash used for the cache key.

    After attempting to restore the cache, run brew install-bundler-gems only if a cache hit did not occur.

    - name: Set up Homebrew
      id: set-up-homebrew
      uses: Homebrew/actions/setup-homebrew@1f8e202ffddf94def7f42f6fa3a482e821489f9c
    
    - name: Cache Homebrew Bundler RubyGems
      id: cache
      uses: actions/cache@v5
      with:
        path: ${{ steps.set-up-homebrew.outputs.gems-path }}
        key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
        restore-keys: ${{ runner.os }}-rubygems-
    
    - name: Install Homebrew Bundler RubyGems
      if: steps.cache.outputs.cache-hit != 'true'
      run: brew install-bundler-gems
  11. Configure git user via git-user-config action

    main

    The git-user-config action globally configures the Git identity (user name and email) for a specified GitHub user within a workflow run. This is useful for ensuring that commits or automated actions are attributed to a specific user rather than the default runner identity.

    By default, if no username is provided, the action uses the value of the $GITHUB_ACTOR environment variable.

    - name: Configure git
      uses: Homebrew/actions/git-user-config@1f8e202ffddf94def7f42f6a3a482e821489f9c # 2026.07.10.1
      with:
        # Defaults to $GITHUB_ACTOR if not specified
        username: BrewTestBot
  12. Use the git-try-push GitHub Action

    main

    The git-try-push action attempts to perform a git push. If the push fails (for example, due to race conditions or transient network issues), the action will wait and retry. You can control the maximum number of attempts using the tries input.

    Inputs

    • token: The GitHub token used for authentication (e.g., ${{ github.token }}).
    • directory: The path to the repository directory where the push should be attempted.
    • remote: The name of the remote to push to (e.g., origin).
    • branch: The name of the branch to push to.
    • tries: The maximum number of times to attempt the push. Defaults to a value determined by the action implementation if not specified.
    - name: Try pushing
      uses: Homebrew/actions/git-try-push@1f8e202ffddf94def7f42f6fa3a482e821489f9c # 2026.07.10.1
      with:
        token: ${{github.token}}
        directory: path/to/repo
        remote: origin
        branch: main
        tries: 20