Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tool/actions-gh-release/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,21 @@ func readFileAtCommit(ctx context.Context, gitExecPath, repoDir, filePath, commi

return bytes.TrimSpace(out), nil
}

func addSafeDirectory(ctx context.Context, gitExecPath, repoDir string) error {
args := []string{
"config",
"--global",
"--add",
"safe.directory",
repoDir,
}

cmd := exec.CommandContext(ctx, gitExecPath, args...)
cmd.Dir = repoDir
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("err: %w, out: %s", err, string(out))
}
return nil
}
4 changes: 4 additions & 0 deletions tool/actions-gh-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func main() {
log.Fatal("GITHUB_WORKSPACE was not defined")
}

if err := addSafeDirectory(ctx, gitExecPath, workspace); err != nil {
log.Fatalf("Failed to add %s as a safe directory: %v\n", workspace, err)
}

cfg := &githubClientConfig{Token: args.Token}
ghClient := newGitHubClient(ctx, cfg)

Expand Down