export async function pushChange()

in src/functions.ts [129:156]


export async function pushChange(
  filePath: string,
  originalBranchSha: string,
  isForcePush: boolean
) {
  const fileName = filePath.replace(".", "_");
  const branchName = `zenn-metadata-updater/${fileName}`;
  let forceFlag: "" | "-f" = "";
  if (isForcePush) {
    forceFlag = "-f";
  }

  await execByThrowError("git", ["switch", "-c", branchName]);
  await execByThrowError("git", ["add", filePath]);
  await execByThrowError("git", [
    "-c",
    "user.email='41898282+github-actions[bot]@users.noreply.github.com'",
    "-c",
    "user.name='github-actions[bot]'",
    "commit",
    "-m",
    getCommitMessage(filePath),
  ]);
  await execByThrowError("git", ["push", forceFlag, "origin", branchName]);
  await execByThrowError("git", ["checkout", originalBranchSha]);

  return branchName;
}