Skip to content

Commit 6310087

Browse files
authored
[ci] Fix download_base_build_for_sizebot (#26422)
CircleCI now enforces passing a token when fetching artifacts. I'm also deleting the old request-promise-json dependency because AFAIK we were only using it to fetch json from circleci about the list of available artifacts – which we can just do using node-fetch. Plus, the underlying request package it uses has been deprecated since 2019.
1 parent 6854a3c commit 6310087

File tree

4 files changed

+22
-311
lines changed

4 files changed

+22
-311
lines changed

scripts/release/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"prompt-promise": "^1.0.3",
2020
"puppeteer": "^1.11.0",
2121
"pushstate-server": "^3.0.1",
22-
"request-promise-json": "^1.0.4",
2322
"semver": "^5.4.1"
2423
}
2524
}

scripts/release/shared-commands/download-build-artifacts.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ const run = async ({build, cwd, releaseChannel}) => {
2222
}
2323

2424
// Download and extract artifact
25+
const {CIRCLE_CI_API_TOKEN} = process.env;
26+
if (CIRCLE_CI_API_TOKEN == null) {
27+
throw new Error(
28+
`Expected a CircleCI token to download artifacts, got ${CIRCLE_CI_API_TOKEN}`
29+
);
30+
}
2531
await exec(`rm -rf ./build`, {cwd});
2632
await exec(
27-
`curl -L $(fwdproxy-config curl) ${buildArtifacts.url} | tar -xvz`,
33+
`curl -L $(fwdproxy-config curl) ${buildArtifacts.url} -H "Circle-Token: ${CIRCLE_CI_API_TOKEN}" | tar -xvz`,
2834
{
2935
cwd,
3036
}

scripts/release/utils.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {createPatch} = require('diff');
55
const {hashElement} = require('folder-hash');
66
const {existsSync, readFileSync, writeFileSync} = require('fs');
77
const {readJson, writeJson} = require('fs-extra');
8-
const http = require('request-promise-json');
8+
const fetch = require('node-fetch');
99
const logUpdate = require('log-update');
1010
const {join} = require('path');
1111
const createLogger = require('progress-estimator');
@@ -59,9 +59,19 @@ const extractCommitFromVersionNumber = version => {
5959
};
6060

6161
const getArtifactsList = async buildID => {
62+
const {CIRCLE_CI_API_TOKEN} = process.env;
63+
if (CIRCLE_CI_API_TOKEN == null) {
64+
throw new Error(
65+
`Expected a CircleCI token to download artifacts, got ${CIRCLE_CI_API_TOKEN}`
66+
);
67+
}
6268
const jobArtifactsURL = `https://circleci.com/api/v1.1/project/github/facebook/react/${buildID}/artifacts`;
63-
const jobArtifacts = await http.get(jobArtifactsURL, true);
64-
return jobArtifacts;
69+
const jobArtifacts = await fetch(jobArtifactsURL, {
70+
headers: {
71+
'Circle-Token': CIRCLE_CI_API_TOKEN,
72+
},
73+
});
74+
return jobArtifacts.json();
6575
};
6676

6777
const getBuildInfo = async () => {

0 commit comments

Comments
 (0)