fix: skip git commit/push in removeCustomerChart if file was never tracked
Some checks failed
Build & Release / build (push) Has been cancelled
Some checks failed
Build & Release / build (push) Has been cancelled
This commit is contained in:
@@ -21,7 +21,8 @@ function withRepo<T>(fn: (dir: string, env: NodeJS.ProcessEnv) => T): T {
|
|||||||
execSync(`git -C ${dir} config user.email "manager@lunarfront.tech"`, { env });
|
execSync(`git -C ${dir} config user.email "manager@lunarfront.tech"`, { env });
|
||||||
execSync(`git -C ${dir} config user.name "lunarfront-manager"`, { env });
|
execSync(`git -C ${dir} config user.name "lunarfront-manager"`, { env });
|
||||||
const result = fn(dir, env);
|
const result = fn(dir, env);
|
||||||
execSync(`git -C ${dir} push origin main`, { env, stdio: "pipe" });
|
const unpushed = execSync(`git -C ${dir} log origin/main..HEAD --oneline`, { env }).toString().trim();
|
||||||
|
if (unpushed) execSync(`git -C ${dir} push origin main`, { env, stdio: "pipe" });
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
rmSync(dir, { recursive: true, force: true });
|
rmSync(dir, { recursive: true, force: true });
|
||||||
@@ -40,7 +41,10 @@ export function addCustomerChart(slug: string, appVersion: string) {
|
|||||||
|
|
||||||
export function removeCustomerChart(slug: string) {
|
export function removeCustomerChart(slug: string) {
|
||||||
withRepo((dir, env) => {
|
withRepo((dir, env) => {
|
||||||
rmSync(join(dir, "customers", `${slug}.yaml`), { force: true });
|
const filePath = join(dir, "customers", `${slug}.yaml`);
|
||||||
|
const tracked = execSync(`git -C ${dir} ls-files customers/${slug}.yaml`, { env }).toString().trim();
|
||||||
|
if (!tracked) return;
|
||||||
|
rmSync(filePath, { force: true });
|
||||||
execSync(`git -C ${dir} add customers/${slug}.yaml`, { env });
|
execSync(`git -C ${dir} add customers/${slug}.yaml`, { env });
|
||||||
execSync(`git -C ${dir} commit -m "chore: deprovision customer ${slug}"`, { env });
|
execSync(`git -C ${dir} commit -m "chore: deprovision customer ${slug}"`, { env });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user