Skip to content

Commit

Permalink
Stream script output and deploy on master or tags (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Jun 5, 2017
1 parent 81055ed commit 92643d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ deploy:
script: scripts/deploy.sh
skip_cleanup: true
on:
tags: true
branch: master
condition: $TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG
11 changes: 8 additions & 3 deletions conform/enforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,15 @@ func (e *Enforcer) ExtractArtifact(artifact string) error {
// ExecuteScript executes a script for a rule.
func (e *Enforcer) ExecuteScript(script string) error {
if s, ok := e.config.Scripts[script]; ok {
log.Printf("Running %s script", script)
out, err := exec.Command("bash", "-c", s).Output()
log.Printf("Running %q script", script)

command := exec.Command("bash", "-c", s)
command.Stdout = os.Stdout
command.Stderr = os.Stderr
command.Start()
err := command.Wait()
if err != nil {
return fmt.Errorf("Failed executing %s: %v\n%s", script, err, out)
return fmt.Errorf("Failed executing %q: %v", script, err)
}

return nil
Expand Down

0 comments on commit 92643d5

Please sign in to comment.