diff --git a/scripts/ci/codegen/pushToRepository.ts b/scripts/ci/codegen/pushToRepository.ts index 8452f3ed163..2fedc7dc610 100644 --- a/scripts/ci/codegen/pushToRepository.ts +++ b/scripts/ci/codegen/pushToRepository.ts @@ -35,11 +35,6 @@ async function handleSpecFiles(spec: SpecsToPush, tempGitDir: string): Promise { @@ -130,31 +130,35 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat await run(`gh repo clone ${OWNER}/${repository} ${tempGitDir}`); for (const task of config.tasks) { + console.log(`Handling '${task.files.type}' file(s)`); + await run(`git checkout ${config.baseBranch}`, { cwd: tempGitDir }); await run(`git pull origin ${config.baseBranch}`, { cwd: tempGitDir }); - - if (await gitBranchExists(task.prBranch, tempGitDir)) { - await run(`git fetch origin ${task.prBranch}`, { cwd: tempGitDir }); - await run(`git push -d origin ${task.prBranch}`, { cwd: tempGitDir }); - } await run(`git checkout -B ${task.prBranch}`, { cwd: tempGitDir }); - console.log(`Handling '${task.files.type}' file(s)`); - if (task.files.type === 'specs') { await handleSpecFiles(task.files, tempGitDir); } else { await handleGuideFiles(task.files, tempGitDir); } + if (process.env.DRYRUN) { + console.log(`asked for a dry run, stopping before push and PR for '${repository}' on task '${task.prBranch}'`); + + continue; + } + + if (await gitBranchExists(task.prBranch, tempGitDir)) { + await run(`git fetch origin ${task.prBranch}`, { cwd: tempGitDir }); + await run(`git push -d origin ${task.prBranch}`, { cwd: tempGitDir }); + } + if ((await getNbGitDiff({ head: null, cwd: tempGitDir })) === 0) { console.log(`❎ Skipping push to ${OWNER}/${repository} because there is no change.`); continue; } - console.log(`Pushing to '${task.prBranch}`); - await configureGitHubAuthor(tempGitDir); await run('git add .', { cwd: tempGitDir }); @@ -164,12 +168,6 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat cwd: tempGitDir, }); - if (process.env.DRYRUN) { - console.log(`asked for a dry run, stopping before push and PR for '${repository}' on task '${task.prBranch}'`); - - continue; - } - await run(`git push -f -u origin ${task.prBranch}`, { cwd: tempGitDir }); console.log(`Creating pull request on ${OWNER}/${repository}...`);