try this
Rick Hanlon committed
Jun 10, 2024 at 10:46 UTC
b6b2ab1e0ce2d0d5df61f21f0201c9a6ec8f253e
1 file changed
+49
-47
.github/workflows/commit_artifacts.yml
+49
-47
@@ -2,7 +2,7 @@ name: Commit Artifacts for Meta WWW and fbsource
2
3
on:
4
push:
5
- branches: [main, meta-www, meta-fbsource]
5
+ branches: [main, meta-www, meta-fbsource, rh/test-ci-new]
6
7
jobs:
8
download_artifacts:
@@ -72,53 +72,55 @@ jobs:
72
});
73
}
74
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;
116
}
110
- break;
111
- }
112
- default: {
113
- throw new Error(`Unhandled status state: ${status.state}`);
114
- break;
117
}
118
}
119
}
120
+ iter++;
121
+ console.log("Sleeping for 60s...");
122
+ await sleep(60_000);
123
}
119
- iter++;
120
- console.log("Sleeping for 60s...");
121
- await sleep(60_000);
124
}
125
if (artifactsUrl != null) {
126
const {CIRCLECI_TOKEN} = process.env;
@@ -222,7 +224,7 @@ jobs:
224
225
commit_www_artifacts:
226
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' }}
228
runs-on: ubuntu-latest
229
steps:
230
- uses: actions/checkout@v4
@@ -305,7 +307,7 @@ jobs:
307
308
commit_fbsource_artifacts:
309
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' }}
311
runs-on: ubuntu-latest
312
steps:
313
- uses: actions/checkout@v4
@@ -389,7 +391,7 @@ jobs:
391
}
392
return data.replace(NEWTOKEN, `SignedSource<<${hash(data, 'utf8')}>>`);
393
},
392
- };
394
+ };
395
396
const directory = './compiled-rn';
397
console.log('Signing files in directory:', directory);
@@ -499,7 +501,7 @@ jobs:
501
}
502
return data.replace(NEWTOKEN, `SignedSource<<${hash(data, 'utf8')}>>`);
503
},
502
- };
504
+ };
505
506
const directory = './compiled-rn';
507
console.log('Signing files in directory:', directory);