Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "setup-homebrew: add brew-gh-api-token setting"" #560

Merged
merged 3 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions setup-homebrew/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
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
Expand Down
5 changes: 3 additions & 2 deletions setup-homebrew/main.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {exec} from "@actions/exec"
import { exec } from "@actions/exec"
import core from "@actions/core"

// GitHub Actions does not support shell `post` actions and thus requires a JS wrapper.
Expand All @@ -10,7 +10,8 @@ try {
core.getInput("test-bot"),
core.getInput("debug"),
core.getInput("token"),
core.getInput("stable")
core.getInput("stable"),
core.getInput("brew-gh-api-token"),
])
} catch (error) {
core.setFailed(error.message)
Expand Down
6 changes: 6 additions & 0 deletions setup-homebrew/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ TEST_BOT="${3}"
DEBUG="${4}"
TOKEN="${5}"
STABLE="${6}"
BREW_GH_API_TOKEN="${7}"

if [[ "${DEBUG}" == "true" ]]; then
set -x
Expand Down Expand Up @@ -122,6 +123,11 @@ if [[ ! "$GITHUB_REPOSITORY" =~ ^.+/(home|linux)brew-core$ ]]; then
unset HOMEBREW_NO_INSTALL_FROM_API
fi

# Configure HOMEBREW_GITHUB_API_TOKEN (needed for attestations)
if [[ -n "${BREW_GH_API_TOKEN}" ]]; then
echo "HOMEBREW_GITHUB_API_TOKEN=${BREW_GH_API_TOKEN}" >> "${GITHUB_ENV}"
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
fi

# Use an access token to checkout (private repositories)
if [[ -n "${TOKEN}" ]]; then
# GNU coreutils will line-wrap long tokens, so delete any newlines.
Expand Down