Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: create parent dir if not exists (#16058)

p0nyda1125911fb2
diff --git a/action/main.go b/action/main.go
index 38d4201035..bd100bc35c 100644
--- a/action/main.go
+++ b/action/main.go
@@ -8,6 +8,7 @@ import (
"net/url"
"os"
"os/signal"
+ "path/filepath"
"slices"
"strings"
"syscall"
@@ -75,6 +76,7 @@ func init() {
}
cmd.AddCommand(cmdCheck)
+ // bytebase-action rollout flags
cmdRollout := &cobra.Command{
Use: "rollout",
Short: "Rollout the migrate files",
@@ -138,6 +140,14 @@ func writeOutputJSON(*cobra.Command, []string) error {
if Config.Output == "" {
return nil
}
+
+ // Create parent directory if not exists
+ if dir := filepath.Dir(Config.Output); dir != "" {
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ return errors.Wrapf(err, "failed to create output directory: %s", dir)
+ }
+ }
+
f, err := os.Create(Config.Output)
if err != nil {
return errors.Wrapf(err, "failed to create output file: %s", Config.Output)