Merge pull request #14263 from ethereum/gh-auth-token-foundry-cmd

Prefer authenticated request to github api when the token is available
This commit is contained in:
Kamil Śliwak 2023-05-26 12:30:11 +02:00 committed by GitHub
commit bb16f61e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,11 +128,15 @@ commands:
command: |
FOUNDRY_REPO="foundry-rs/foundry"
FOUNDRY_VERSION="<< parameters.version >>"
# Make authenticated requests when the Github token is available
if [[ -n "$GITHUB_ACCESS_TOKEN" ]]; then
EXTRA_HEADERS=(--header 'Authorization: Bearer '"${GITHUB_ACCESS_TOKEN}")
fi
FOUNDRY_RELEASE_SHA=$(curl \
--silent \
--fail \
--show-error \
--header "Authorization: Bearer ${GITHUB_ACCESS_TOKEN}" \
"${EXTRA_HEADERS[@]}" \
"https://api.github.com/repos/${FOUNDRY_REPO}/git/refs/tags/${FOUNDRY_VERSION}" \
| jq --raw-output .object.sha \
)