Compare commits
No commits in common. "f6e4e64e81136f2d89a437b7374e51beace1c059" and "9c735ccf647f7ae83b1f3c04998f39f253e838c4" have entirely different histories.
f6e4e64e81
...
9c735ccf64
|
@ -12,9 +12,9 @@ type Config struct {
|
|||
Projects map[string][]ConfigScript `yaml:"projects"`
|
||||
}
|
||||
type ConfigScript struct {
|
||||
Environment string `yaml:"environment"`
|
||||
Command string `yaml:"command"`
|
||||
Arguments []string `yaml:"args"`
|
||||
Environment string `yaml:"environment"`
|
||||
Command string `yaml:"command"`
|
||||
Arguments string `yaml:"args"`
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
|
|
10
main.go
10
main.go
|
@ -27,8 +27,8 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("Error loading config: %v", err)
|
||||
}
|
||||
log.Println("GOOO")
|
||||
http.HandleFunc("/", handlePayload(cfg.Secret, cfg.Projects))
|
||||
log.Printf("server is up on %d\n", cfg.Port)
|
||||
http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil)
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,6 @@ func handlePayload(secret string, projects map[string][]config.ConfigScript) fun
|
|||
proj, found := projects[project]
|
||||
if !found {
|
||||
http.Error(w, "not found", http.StatusNotFound)
|
||||
log.Printf("project %s not found\n", project)
|
||||
return
|
||||
}
|
||||
var payload internal.WebhookPayload
|
||||
|
@ -78,20 +77,19 @@ func handlePayload(secret string, projects map[string][]config.ConfigScript) fun
|
|||
}
|
||||
if !found {
|
||||
http.Error(w, "not found", http.StatusNotFound)
|
||||
log.Printf("project %s with branch %s not found\n", project, branchName)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := execute(scr.Command, scr.Arguments...); err != nil {
|
||||
if err := execute(scr.Command, scr.Arguments); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
func execute(command string, args ...string) error {
|
||||
cmd := exec.Command(command, args...)
|
||||
func execute(command, args string) error {
|
||||
cmd := exec.Command(command, args)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
|
|
Loading…
Reference in New Issue