@samitouri / QOS-React-1 / commits / a34aa05e69

[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

lauren committed Dec 18, 2024 at 20:09 UTC a34aa05e6991b6ec82986b56b786bcd497ed8aa1
1 file changed +10 -17
scripts/release/shared-commands/download-build-artifacts.js
+10 -17
@@ -39,18 +39,16 @@ function getWorkflowId() {
39
40 async function getWorkflowRun(commit) {
41 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}`
43 );
44
45 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 + );
52
53 if (workflowRun == null || workflowRun.id == null) {
54 console.log(
@@ -68,14 +66,9 @@ async function getArtifact(workflowRunId, artifactName) {
66 );
67
68 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 + );
72
73 if (artifact == null) {
74 console.log(