Skip to content

Commit 6e2563e

Browse files
committed
fix(scripts): push to repository
1 parent 02b13b5 commit 6e2563e

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

scripts/ci/codegen/pushToRepository.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ async function handleSpecFiles(spec: SpecsToPush, tempGitDir: string): Promise<v
3535
await run(`cp ${toAbsolutePath('docs/versions-history-with-sla-and-support-policy.json')} ${output}`);
3636
}
3737

38-
// adblock extensions ban words like `analytics` so we use a different file name just so the doc dans render it
39-
if (spec.ext === 'yml') {
40-
await run(`mv ${output}/analytics.yml ${output}/searchstats.yml`);
41-
}
42-
4338
for (const client of CLIENTS) {
4439
const pathToBundledSpec = toAbsolutePath(`docs/bundled/${client}.${spec.ext}`);
4540

@@ -55,12 +50,17 @@ async function handleSpecFiles(spec: SpecsToPush, tempGitDir: string): Promise<v
5550
let file = await fsp.readFile(outputFile, 'utf8');
5651

5752
for (const [k, v] of Object.entries(spec.placeholderVariables)) {
58-
file = file.replace(k, v);
53+
file = file.replaceAll(k, v);
5954
}
6055

6156
await fsp.writeFile(outputFile, file);
6257
}
6358
}
59+
60+
// adblock extensions ban words like `analytics` so we use a different file name just so the doc dans render it
61+
if (spec.ext === 'yml') {
62+
await run(`mv ${output}/analytics.yml ${output}/searchstats.yml`);
63+
}
6464
}
6565

6666
async function handleGuideFiles(guide: GuidesToPush, tempGitDir: string): Promise<void> {
@@ -130,23 +130,29 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
130130
await run(`gh repo clone ${OWNER}/${repository} ${tempGitDir}`);
131131

132132
for (const task of config.tasks) {
133+
console.log(`Handling '${task.files.type}' file(s)`);
134+
133135
await run(`git checkout ${config.baseBranch}`, { cwd: tempGitDir });
134136
await run(`git pull origin ${config.baseBranch}`, { cwd: tempGitDir });
135-
136-
if (await gitBranchExists(task.prBranch, tempGitDir)) {
137-
await run(`git fetch origin ${task.prBranch}`, { cwd: tempGitDir });
138-
await run(`git push -d origin ${task.prBranch}`, { cwd: tempGitDir });
139-
}
140137
await run(`git checkout -B ${task.prBranch}`, { cwd: tempGitDir });
141138

142-
console.log(`Handling '${task.files.type}' file(s)`);
143-
144139
if (task.files.type === 'specs') {
145140
await handleSpecFiles(task.files, tempGitDir);
146141
} else {
147142
await handleGuideFiles(task.files, tempGitDir);
148143
}
149144

145+
if (process.env.DRYRUN) {
146+
console.log(`asked for a dry run, stopping before push and PR for '${repository}' on task '${task.prBranch}'`);
147+
148+
continue;
149+
}
150+
151+
if (await gitBranchExists(task.prBranch, tempGitDir)) {
152+
await run(`git fetch origin ${task.prBranch}`, { cwd: tempGitDir });
153+
await run(`git push -d origin ${task.prBranch}`, { cwd: tempGitDir });
154+
}
155+
150156
if ((await getNbGitDiff({ head: null, cwd: tempGitDir })) === 0) {
151157
console.log(`❎ Skipping push to ${OWNER}/${repository} because there is no change.`);
152158

@@ -164,12 +170,6 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
164170
cwd: tempGitDir,
165171
});
166172

167-
if (process.env.DRYRUN) {
168-
console.log(`asked for a dry run, stopping before push and PR for '${repository}' on task '${task.prBranch}'`);
169-
170-
continue;
171-
}
172-
173173
await run(`git push -f -u origin ${task.prBranch}`, { cwd: tempGitDir });
174174

175175
console.log(`Creating pull request on ${OWNER}/${repository}...`);

0 commit comments

Comments
 (0)