@@ -17919,6 +17919,7 @@ var main = async () => {
17919
17919
const commitMessage = core.getInput("commit_message") || "Repo visualizer: updated diagram";
17920
17920
const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock";
17921
17921
const excludedPaths = excludedPathsString.split(",").map((str) => str.trim());
17922
+ const branch = core.getInput("branch");
17922
17923
const data = await processDir(`./`, excludedPaths);
17923
17924
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
17924
17925
data,
@@ -17927,6 +17928,18 @@ var main = async () => {
17927
17928
}));
17928
17929
const outputFile = core.getInput("output_file") || "./diagram.svg";
17929
17930
await import_fs2.default.writeFileSync(outputFile, componentCodeString);
17931
+ let doesBranchExist = true;
17932
+ if (branch) {
17933
+ await (0, import_exec.exec)("git", ["fetch"]);
17934
+ try {
17935
+ await (0, import_exec.exec)("git", ["rev-parse", "--verify", branch]);
17936
+ await (0, import_exec.exec)("git", ["checkout", branch]);
17937
+ } catch {
17938
+ doesBranchExist = false;
17939
+ core.info(`Branch ${branch} does not yet exist, creating ${branch}.`);
17940
+ await (0, import_exec.exec)("git", ["checkout", "-b", branch]);
17941
+ }
17942
+ }
17930
17943
await (0, import_exec.exec)("git", ["add", outputFile]);
17931
17944
const diff = await execWithOutput("git", ["status", "--porcelain", outputFile]);
17932
17945
core.info(`diff: ${diff}`);
@@ -17935,7 +17948,14 @@ var main = async () => {
17935
17948
return;
17936
17949
}
17937
17950
await (0, import_exec.exec)("git", ["commit", "-m", commitMessage]);
17938
- await (0, import_exec.exec)("git", ["push"]);
17951
+ if (doesBranchExist) {
17952
+ await (0, import_exec.exec)("git", ["push"]);
17953
+ } else {
17954
+ await (0, import_exec.exec)("git", ["push", "--set-upstream", "origin", branch]);
17955
+ }
17956
+ if (branch) {
17957
+ await (0, import_exec.exec)("git", "checkout", "-");
17958
+ }
17939
17959
console.log("All set!");
17940
17960
};
17941
17961
main();
0 commit comments