Skip to content

Commit

Permalink
[ci] Fix download_base_build_for_sizebot
Browse files Browse the repository at this point in the history
CircleCI now enforces passing a token when fetching artifacts.
  • Loading branch information
poteto committed Mar 17, 2023
1 parent 6854a3c commit a509562
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 7 additions & 1 deletion scripts/release/shared-commands/download-build-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
15 changes: 14 additions & 1 deletion scripts/release/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit a509562

Please sign in to comment.