Make auth optional for nvm and ruby scripts (#5030)

This commit is contained in:
Mikhail Timofeev
2022-02-07 12:08:46 +03:00
committed by GitHub
parent 0740ab86e6
commit bb66e542a3
2 changed files with 4 additions and 2 deletions

View File

@@ -5,7 +5,8 @@
########################################################################### ###########################################################################
source ~/utils/utils.sh source ~/utils/utils.sh
VERSION=$(curl -H "Authorization: token $API_PAT" -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name') [ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
VERSION=$(curl "${authString[@]}" -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name')
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh | bash
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then

View File

@@ -10,7 +10,8 @@ echo "GEM_PATH=$GEM_PATH" >> "$HOME/.bashrc"
echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> "$HOME/.bashrc" echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> "$HOME/.bashrc"
echo "Install Ruby from toolset..." echo "Install Ruby from toolset..."
PACKAGE_TAR_NAMES=$(curl -H "Authorization: token $API_PAT" -s "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name') [ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
PACKAGE_TAR_NAMES=$(curl "${authString[@]}" -s "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .versions[]') TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .versions[]')
RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby" RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby"