-
Notifications
You must be signed in to change notification settings - Fork 25
update handling of GitHub auth for local, interactive use #172
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ set -euo pipefail | |
| export RAPIDS_SCRIPT_NAME="rapids-download-conda-from-github" | ||
|
|
||
| source rapids-prompt-local-repo-config | ||
| source rapids-prompt-local-github-auth | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this because this script doesn't directly call the Found those like this: git grep 'gh ' |
||
|
|
||
| # Validate package type argument | ||
| pkg_type="$1" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,13 @@ | |
| set -euo pipefail | ||
| export RAPIDS_SCRIPT_NAME="rapids-download-from-github" | ||
|
|
||
| if [ -z "$1" ]; then | ||
| if [ -z "${1:-}" ]; then | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of rapids-download-from-github
# tools/rapids-download-from-github: line 9: $1: unbound variable
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I observed this too and didn’t realize it was a bug. 🥲
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha yup! Same thing as conda-forge/arrow-cpp-feedstock#1696, it's easy to trip over stuff like this with |
||
| rapids-echo-stderr "Must specify input arguments: PKG_NAME" | ||
| exit 1 | ||
| fi | ||
|
|
||
| source rapids-prompt-local-github-auth | ||
|
|
||
| github_run_id="$(rapids-github-run-id)" | ||
| pkg_name="$1" | ||
| unzip_dest="${RAPIDS_UNZIP_DIR:-$(mktemp -d)}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,30 @@ | ||
| #!/bin/bash | ||
| # | ||
| # A utility script that prompts user to authenticate with GitHub in | ||
| # local environments | ||
| # Checks if the current environment is authenticated to communicate with the GitHub API. | ||
| # | ||
| # If not, prompts for an interactive login to generate short-lived credentials. | ||
| # | ||
| # This exists primarily for interactive use cases, like trying to reproduce CI locally. | ||
| # | ||
|
|
||
| if ! gh auth status >/dev/null 2>&1; then | ||
| rapids-echo-stderr "No GitHub authentication detected." | ||
| rapids-echo-stderr "Please authenticate with GitHub to continue." | ||
| rapids-echo-stderr "To avoid these interactive prompts in the future, set environment variable 'GH_TOKEN' or run 'gh auth login' with the GitHub CLI." | ||
|
|
||
| if [ -z "${GH_TOKEN:-}" ] && [ -z "${GITHUB_TOKEN:-}" ]; then | ||
| rapids-echo-stderr "No GitHub token detected in environment" | ||
| rapids-echo-stderr "Please authenticate with GitHub to continue" | ||
| gh auth login --web --git-protocol https | ||
| # Prompt for interactive login. | ||
| # | ||
| # By omitting --scopes, this will generate a short-lived GitHub auth token | ||
| # with only the minimum required scopes. | ||
| # | ||
| # You can run 'gh auth status' afterwards to check the scopes the GitHub CLI granted. | ||
| if ! gh auth login \ | ||
| --web \ | ||
| --git-protocol https \ | ||
| --hostname "github.com" \ | ||
| --skip-ssh-key; | ||
| then | ||
| rapids-echo-stderr "GitHub authentication failed. Exiting."; | ||
| exit 1; | ||
| fi | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I came to this conclusion too: #171 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! Everywhere that we invoke
ghin a tool that might be used interactively, this should be called.The
if gh auth statusmakes it idempotent (ensures you aren't put through the interactive login workflow multiple times).