From a509562454548040e21fed20f7b17b7f29c5192f Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 17 Mar 2023 15:17:36 -0400 Subject: [PATCH] [ci] Fix download_base_build_for_sizebot CircleCI now enforces passing a token when fetching artifacts. --- .../shared-commands/download-build-artifacts.js | 8 +++++++- scripts/release/utils.js | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/release/shared-commands/download-build-artifacts.js b/scripts/release/shared-commands/download-build-artifacts.js index fba7465202739..3396fe33a69fa 100644 --- a/scripts/release/shared-commands/download-build-artifacts.js +++ b/scripts/release/shared-commands/download-build-artifacts.js @@ -22,9 +22,15 @@ const run = async ({build, cwd, releaseChannel}) => { } // Download and extract artifact + const {CIRCLE_CI_API_TOKEN} = process.env; + if (CIRCLE_CI_API_TOKEN == null) { + throw new Error( + `Expected a CircleCI token to download artifacts, got ${CIRCLE_CI_API_TOKEN}` + ); + } await exec(`rm -rf ./build`, {cwd}); await exec( - `curl -L $(fwdproxy-config curl) ${buildArtifacts.url} | tar -xvz`, + `curl -L $(fwdproxy-config curl) ${buildArtifacts.url} -H "Circle-Token: ${CIRCLE_CI_API_TOKEN}" | tar -xvz`, { cwd, } diff --git a/scripts/release/utils.js b/scripts/release/utils.js index 7a940f8f65fb4..ccbdc4e7015e2 100644 --- a/scripts/release/utils.js +++ b/scripts/release/utils.js @@ -59,8 +59,21 @@ const extractCommitFromVersionNumber = version => { }; const getArtifactsList = async buildID => { + const {CIRCLE_CI_API_TOKEN} = process.env; + if (CIRCLE_CI_API_TOKEN == null) { + throw new Error( + `Expected a CircleCI token to download artifacts, got ${CIRCLE_CI_API_TOKEN}` + ); + } const jobArtifactsURL = `https://circleci.com/api/v1.1/project/github/facebook/react/${buildID}/artifacts`; - const jobArtifacts = await http.get(jobArtifactsURL, true); + const jobArtifacts = await http({ + method: 'GET', + url: jobArtifactsURL, + headers: { + 'Circle-Token': CIRCLE_CI_API_TOKEN, + }, + json: true, + }); return jobArtifacts; };