diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 468addf98e..a04c2bd423 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -126,11 +126,12 @@ module Homebrew "such as `brew search`. We strongly recommend using `HOMEBREW_GITHUB_API_TOKEN` instead.", }, HOMEBREW_GITHUB_API_TOKEN: { - description: "A personal access token for the GitHub API, used by Homebrew for features such as " \ + description: "A personal access token for the GitHub API, used by Homebrew for features such as " \ "`brew search`. You can create one at . If set, " \ "GitHub will allow you a greater number of API requests. For more information, see: " \ "\n\n *Note:* Homebrew doesn't " \ "require permissions for any of the scopes.", + default_text: "`$GITHUB_TOKEN`.", }, HOMEBREW_GITHUB_API_USERNAME: { description: "GitHub username for authentication with the GitHub API, used by Homebrew for features " \ diff --git a/bin/brew b/bin/brew index ef4cc6ef49..9e5f02c18a 100755 --- a/bin/brew +++ b/bin/brew @@ -79,6 +79,12 @@ then export HOMEBREW_EDITOR="$VISUAL" fi +# Use GITHUB_TOKEN if HOMEBREW_GITHUB_API_TOKEN is unset. +if [[ -z "$HOMEBREW_GITHUB_API_TOKEN" && -n "$GITHUB_TOKEN" ]] +then + export HOMEBREW_GITHUB_API_TOKEN="$GITHUB_TOKEN" +fi + # Set CI variable for GitHub Actions, Azure Pipelines, Jenkins # (Set by default on Circle and Travis CI) if [[ -n "$GITHUB_ACTIONS" || -n "$TF_BUILD" || -n "$JENKINS_HOME" ]] diff --git a/docs/Manpage.md b/docs/Manpage.md index d333fd1e2c..4ee618eb7e 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1282,6 +1282,8 @@ Note that environment variables must have a value set to be detected. For exampl *Note:* Homebrew doesn't require permissions for any of the scopes. + *Default:* `$GITHUB_TOKEN`. + * `HOMEBREW_GITHUB_API_USERNAME`: GitHub username for authentication with the GitHub API, used by Homebrew for features such as `brew search`. We strongly recommend using `HOMEBREW_GITHUB_API_TOKEN` instead. diff --git a/manpages/brew.1 b/manpages/brew.1 index 0b3cb2b129..3fcc451a7f 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1637,6 +1637,9 @@ A personal access token for the GitHub API, used by Homebrew for features such a .IP \fINote:\fR Homebrew doesn\'t require permissions for any of the scopes\. . +.IP +\fIDefault:\fR \fB$GITHUB_TOKEN\fR\. +. .TP \fBHOMEBREW_GITHUB_API_USERNAME\fR GitHub username for authentication with the GitHub API, used by Homebrew for features such as \fBbrew search\fR\. We strongly recommend using \fBHOMEBREW_GITHUB_API_TOKEN\fR instead\.