Skip to content

Commit a34aa05

Browse files
authored
[ci] Allow build artifacts to be downloaded from any branch (#31846)
This was previously scoped to just commits on `main` but this restriction is unnecessary. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31846). * #31848 * #31847 * __->__ #31846
1 parent faf6c4d commit a34aa05

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,16 @@ function getWorkflowId() {
3939

4040
async function getWorkflowRun(commit) {
4141
const res = await exec(
42-
`curl -L ${GITHUB_HEADERS} https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${getWorkflowId()}/runs?head_sha=${commit}&branch=main&exclude_pull_requests=true`
42+
`curl -L ${GITHUB_HEADERS} https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${getWorkflowId()}/runs?head_sha=${commit}`
4343
);
4444

4545
const json = JSON.parse(res.stdout);
46-
let workflowRun;
47-
if (json.total_count === 1) {
48-
workflowRun = json.workflow_runs[0];
49-
} else {
50-
workflowRun = json.workflow_runs.find(
51-
run => run.head_sha === commit && run.head_branch === 'main'
52-
);
53-
}
46+
const workflowRun = json.workflow_runs.find(
47+
run =>
48+
run.head_sha === commit &&
49+
run.status === 'completed' &&
50+
run.conclusion === 'success'
51+
);
5452

5553
if (workflowRun == null || workflowRun.id == null) {
5654
console.log(
@@ -68,14 +66,9 @@ async function getArtifact(workflowRunId, artifactName) {
6866
);
6967

7068
const json = JSON.parse(res.stdout);
71-
let artifact;
72-
if (json.total_count === 1) {
73-
artifact = json.artifacts[0];
74-
} else {
75-
artifact = json.artifacts.find(
76-
_artifact => _artifact.name === artifactName
77-
);
78-
}
69+
const artifact = json.artifacts.find(
70+
_artifact => _artifact.name === artifactName
71+
);
7972

8073
if (artifact == null) {
8174
console.log(

0 commit comments

Comments
 (0)