Skip to content

Commit

Permalink
feat: add contrib action "Homebrew/actions/setup-homebrew" at version…
Browse files Browse the repository at this point in the history
… master#83bed10
  • Loading branch information
esolitos authored and gitbutler-client committed Aug 19, 2024
1 parent 2773cdb commit 0fac3b8
Show file tree
Hide file tree
Showing 7 changed files with 445 additions and 0 deletions.
31 changes: 31 additions & 0 deletions github/setup-homebrew/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Setup Homebrew Github Action

An action that sets up a Homebrew environment.

Runs on `ubuntu` and `macos`.

## Usage

```yaml
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
```
This also sets up the variables necessary to cache the gems installed by Homebrew developer commands (e.g. `brew style`). To use these add:

```yaml
- name: Cache Homebrew Bundler RubyGems
id: cache
uses: actions/cache@v3
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
```

Note you do not need to use the `actions/setup-ruby` or `actions/checkout` steps because this action will install the necessary Ruby for Homebrew and checkout the repository being tested.
46 changes: 46 additions & 0 deletions github/setup-homebrew/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Setup Homebrew
description: Set up Homebrew environment
author: dawidd6
branding:
icon: settings
color: yellow
inputs:
core:
description: Update the `homebrew/core` tap.
required: false
default: false
cask:
description: Update the `homebrew/cask` tap.
required: false
default: false
test-bot:
description: Install the `homebrew/test-bot` tap.
required: false
default: auto
debug:
description: Show debugging output
required: false
default: ${{ runner.debug == '1' }}
token:
description: Token to be used for GitHub authentication (if using private repositories). This token will persist through other steps for the duration of the job.
required: false
default: ""
brew-gh-api-token:
description: Token to be used for GitHub API operations within `brew`. This is confusingly not the same thing as `token` above.
required: false
default: "${{ github.token }}"
stable:
description: Use the latest stable `homebrew/brew` tag.
required: false
default: false
outputs:
repository-path:
description: Path to where the repository has been checked out (if applicable)
gems-path:
description: Homebrew's Ruby gems path
gems-hash:
description: Homebrew's Ruby Gemfile.lock sha256sum
runs:
using: node20
main: main.mjs
post: post.mjs
18 changes: 18 additions & 0 deletions github/setup-homebrew/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { exec } from "@actions/exec"
import core from "@actions/core"

// GitHub Actions does not support shell `post` actions and thus requires a JS wrapper.
try {
await exec("/bin/bash", [
new URL("./main.sh", import.meta.url).pathname,
core.getInput("core"),
core.getInput("cask"),
core.getInput("test-bot"),
core.getInput("debug"),
core.getInput("token"),
core.getInput("stable"),
core.getInput("brew-gh-api-token"),
])
} catch (error) {
core.setFailed(error.message)
}
Loading

0 comments on commit 0fac3b8

Please sign in to comment.