Remove secret from previous step

This commit is contained in:
Volodymyr Zotov
2025-08-20 10:28:18 -05:00
parent 91a9bb6d63
commit e167db2357
4 changed files with 27 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
@@ -27,3 +28,26 @@ func Run(name string, args ...string) (string, error) {
return string(output), nil
}
func GetProjectRoot() (string, error) {
dir, err := os.Getwd()
if err != nil {
return "", err
}
for {
// check if go.mod exists in current dir
modFile := filepath.Join(dir, "go.mod")
if _, err := os.Stat(modFile); err == nil {
return dir, nil
}
// move one level up
parent := filepath.Dir(dir)
if parent == dir {
// reached filesystem root
return "", fmt.Errorf("project root not found (no go.mod)")
}
dir = parent
}
}