Skip to content

Commit

Permalink
Prefer authenticated request to github api when the token is available
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Śliwak <[email protected]>
  • Loading branch information
r0qs and cameel committed May 26, 2023
1 parent 02a07fd commit f09838a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
)
Expand Down

0 comments on commit f09838a

Please sign in to comment.