@@ -17919,6 +17919,7 @@ var main = async () => {
1791917919 const commitMessage = core.getInput("commit_message") || "Repo visualizer: updated diagram";
1792017920 const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock";
1792117921 const excludedPaths = excludedPathsString.split(",").map((str) => str.trim());
17922+ const branch = core.getInput("branch");
1792217923 const data = await processDir(`./`, excludedPaths);
1792317924 const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
1792417925 data,
@@ -17927,6 +17928,18 @@ var main = async () => {
1792717928 }));
1792817929 const outputFile = core.getInput("output_file") || "./diagram.svg";
1792917930 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+ }
1793017943 await (0, import_exec.exec)("git", ["add", outputFile]);
1793117944 const diff = await execWithOutput("git", ["status", "--porcelain", outputFile]);
1793217945 core.info(`diff: ${diff}`);
@@ -17935,7 +17948,14 @@ var main = async () => {
1793517948 return;
1793617949 }
1793717950 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+ }
1793917959 console.log("All set!");
1794017960};
1794117961main();
0 commit comments