Prefer authenticated request to github api when the token is available

Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
r0qs 2023-05-24 12:20:35 +02:00
parent 02a07fdf46
commit f09838a03d
No known key found for this signature in database
GPG Key ID: 61503DBA6667276C

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 \
)