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

Add a way to specify github token for downloading binaries, can pass workflow generated token #29

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kirillbilchenko
Copy link

Add a way to specify github token for downloading binaries, can pass workflow generated token

@jtyr
Copy link
Owner

jtyr commented Feb 12, 2024

Thanks for your PR, @kirillbilchenko. May I ask you why do you need to pass a GH token to download files from a public repo?

@kirillbilchenko
Copy link
Author

This one is useful if you are having nat, and for example multiple apps working with github api, so you will not rate limit for non auth calls.

@jtyr
Copy link
Owner

jtyr commented Mar 10, 2024

I see. What about to put something like this above the if [ $DOWNLOADER = 'curl' ]; then:

if [ -z "${GITHUB_TOKEN}" ]; then
  header="--header='Authorization: Bearer ${GITHUB_TOKEN}'"
fi

And then in each of the command just add it like this:

DOWNLOAD_URL=$(curl -sL "$header" "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null)
PROJECT_CHECKSUM=$(curl -sL "$header" "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null)

That should help to reduce the code redundancy a little bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants