Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Circle CI API token to request header if available #26519

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
let header = '';
// Add Circle CI API token to request header if available.
if (CIRCLE_CI_API_TOKEN != null) {
header = '-H "Circle-Token: ${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} ${header}| tar -xvz`,
{
cwd,
}
Expand Down
7 changes: 6 additions & 1 deletion scripts/release/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ const extractCommitFromVersionNumber = version => {
};

const getArtifactsList = async buildID => {
const headers = {};
const {CIRCLE_CI_API_TOKEN} = process.env;
if (CIRCLE_CI_API_TOKEN != null) {
headers['Circle-Token'] = CIRCLE_CI_API_TOKEN;
}
const jobArtifactsURL = `https://circleci.com/api/v1.1/project/github/facebook/react/${buildID}/artifacts`;
const jobArtifacts = await fetch(jobArtifactsURL);
const jobArtifacts = await fetch(jobArtifactsURL, {headers});
return jobArtifacts.json();
};

Expand Down