Skip to content

Commit b6b2ab1

Browse files
committed
try this
1 parent 6b35ff7 commit b6b2ab1

File tree

1 file changed

+49
-47
lines changed

1 file changed

+49
-47
lines changed

.github/workflows/commit_artifacts.yml

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Commit Artifacts for Meta WWW and fbsource
22

33
on:
44
push:
5-
branches: [main, meta-www, meta-fbsource]
5+
branches: [main, meta-www, meta-fbsource, rh/test-ci-new]
66

77
jobs:
88
download_artifacts:
@@ -72,53 +72,55 @@ jobs:
7272
});
7373
}
7474
75-
let artifactsUrl = null;
76-
// This is a temporary, dirty hack to avoid needing a GitHub auth token in the circleci
77-
// workflow to notify this GitHub action. Sorry!
78-
let iter = 0;
79-
spinloop: while (iter < 15) {
80-
const res = await github.rest.repos.listCommitStatusesForRef({
81-
owner: context.repo.owner,
82-
repo: context.repo.repo,
83-
ref: context.sha
84-
});
85-
for (const status of res.data) {
86-
if (/process_artifacts_combined/.test(status.context)) {
87-
switch (status.state) {
88-
case 'pending': {
89-
console.log(`${status.context} is still pending`);
90-
break;
91-
}
92-
case 'failure':
93-
case 'error': {
94-
throw new Error(`${status.context} has failed or errored`);
95-
}
96-
case 'success': {
97-
// The status does not include a build ID, but we can extract it
98-
// from the URL. I couldn't find a better way to do this.
99-
const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec(
100-
status.target_url,
101-
)[1];
102-
if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) {
103-
artifactsUrl =
104-
`https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`;
105-
console.log(`Found artifactsUrl: ${artifactsUrl}`);
106-
break spinloop;
107-
} else {
108-
throw new Error(`${ciBuildId} isn't a number`);
75+
let artifactsUrl = `https://circleci.com/api/v1.1/project/github/facebook/react/905149/artifacts`;
76+
if (!artifactsUrl) {
77+
// This is a temporary, dirty hack to avoid needing a GitHub auth token in the circleci
78+
// workflow to notify this GitHub action. Sorry!
79+
let iter = 0;
80+
spinloop: while (iter < 15) {
81+
const res = await github.rest.repos.listCommitStatusesForRef({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
ref: context.sha
85+
});
86+
for (const status of res.data) {
87+
if (/process_artifacts_combined/.test(status.context)) {
88+
switch (status.state) {
89+
case 'pending': {
90+
console.log(`${status.context} is still pending`);
91+
break;
92+
}
93+
case 'failure':
94+
case 'error': {
95+
throw new Error(`${status.context} has failed or errored`);
96+
}
97+
case 'success': {
98+
// The status does not include a build ID, but we can extract it
99+
// from the URL. I couldn't find a better way to do this.
100+
const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec(
101+
status.target_url,
102+
)[1];
103+
if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) {
104+
artifactsUrl =
105+
`https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`;
106+
console.log(`Found artifactsUrl: ${artifactsUrl}`);
107+
break spinloop;
108+
} else {
109+
throw new Error(`${ciBuildId} isn't a number`);
110+
}
111+
break;
112+
}
113+
default: {
114+
throw new Error(`Unhandled status state: ${status.state}`);
115+
break;
109116
}
110-
break;
111-
}
112-
default: {
113-
throw new Error(`Unhandled status state: ${status.state}`);
114-
break;
115117
}
116118
}
117119
}
120+
iter++;
121+
console.log("Sleeping for 60s...");
122+
await sleep(60_000);
118123
}
119-
iter++;
120-
console.log("Sleeping for 60s...");
121-
await sleep(60_000);
122124
}
123125
if (artifactsUrl != null) {
124126
const {CIRCLECI_TOKEN} = process.env;
@@ -222,7 +224,7 @@ jobs:
222224

223225
commit_www_artifacts:
224226
needs: download_artifacts
225-
if: ${{ (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.www_branch_count == '0') || github.ref == 'refs/heads/meta-www' }}
227+
if: ${{ (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.www_branch_count == '0') || github.ref == 'refs/heads/meta-www' || github.ref == 'refs/heads/rh/test-ci-new' }}
226228
runs-on: ubuntu-latest
227229
steps:
228230
- uses: actions/checkout@v4
@@ -305,7 +307,7 @@ jobs:
305307

306308
commit_fbsource_artifacts:
307309
needs: download_artifacts
308-
if: ${{ (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.fbsource_branch_count == '0') || github.ref == 'refs/heads/meta-fbsource' }}
310+
if: ${{ (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.fbsource_branch_count == '0') || github.ref == 'refs/heads/meta-fbsource' || github.ref == 'refs/heads/rh/test-ci-new' }}
309311
runs-on: ubuntu-latest
310312
steps:
311313
- uses: actions/checkout@v4
@@ -389,7 +391,7 @@ jobs:
389391
}
390392
return data.replace(NEWTOKEN, `SignedSource<<${hash(data, 'utf8')}>>`);
391393
},
392-
};
394+
};
393395
394396
const directory = './compiled-rn';
395397
console.log('Signing files in directory:', directory);
@@ -499,7 +501,7 @@ jobs:
499501
}
500502
return data.replace(NEWTOKEN, `SignedSource<<${hash(data, 'utf8')}>>`);
501503
},
502-
};
504+
};
503505
504506
const directory = './compiled-rn';
505507
console.log('Signing files in directory:', directory);

0 commit comments

Comments
 (0)