Skip to content

Commit ec4561f

Browse files
authored
chore(ci): stop CI from push generated code when no up to date (#421)
1 parent aedf57f commit ec4561f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/ci/codegen/pushGeneratedCode.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import text from './text';
88
const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10);
99
const FOLDERS_TO_CHECK = 'yarn.lock openapitools.json clients specs/bundled';
1010

11+
async function isUpToDate(): Promise<boolean> {
12+
await run('git fetch origin');
13+
return (await run('git status')).includes('Your branch is up to date with');
14+
}
15+
1116
/**
1217
* Push generated code for the current `JOB` and `CLIENT` on a `generated/` branch.
1318
*/
@@ -50,6 +55,13 @@ export async function pushGeneratedCode(): Promise<void> {
5055
await run(`git checkout -b ${branchToPush}`);
5156
}
5257

58+
if (!(await isUpToDate())) {
59+
console.log(
60+
`The branch ${branchToPush} is not up to date with ${baseBranch}, stopping this task and letting the new job push generated code.`
61+
);
62+
return;
63+
}
64+
5365
const commitMessage = await run(`git show -s ${baseBranch} --format="${
5466
text.commitStartMessage
5567
} %H. ${isMainBranch ? '[skip ci]' : ''}

0 commit comments

Comments
 (0)