From f09838a03d4426eee126d8bb139b8399e40d44da Mon Sep 17 00:00:00 2001 From: r0qs Date: Wed, 24 May 2023 12:20:35 +0200 Subject: [PATCH] Prefer authenticated request to github api when the token is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil ƚliwak --- .circleci/config.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d56106f69..6db33891a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 \ )