diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -3,6 +3,7 @@ package main // see `man 5 githooks` for details import ( + "bytes" "errors" "fmt" "io" @@ -32,7 +33,9 @@ func main() { } log.Printf("Git ref update: %s\n", update) commit := update.updated - _ = prepareWorkbench(repo, commit) + workbench := prepareWorkbench(repo, commit) + defer os.RemoveAll(workbench) + craft(workbench) } } @@ -48,12 +51,30 @@ func runCommand(dir string, name string, args ...string) { } } +func craft(workbench string) { + script := `#!/bin/sh + +source craft.sh +build +` + + cmd := exec.Command("busybox", "ash") + cmd.Dir = workbench + cmd.Stdin = bytes.NewBufferString(script) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err := cmd.Run() + if err != nil { + log.Fatal(err) + } +} + func prepareWorkbench(repo string, commit string) string { workbench, err := os.MkdirTemp("", "*-craft") if err != nil { log.Fatal(err) } - defer os.RemoveAll(workbench) runCommand( workbench, |