Skip to content

Commit 31b5b13

Browse files
committed
fix: give more flexibilty for running post deployment commands
1 parent 398800a commit 31b5b13

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ deployments:
3131
type: lambda
3232
version: v2
3333
version-environment-key: VERSION # optional, updates the given environment variable with the version when deploying
34-
post-deploy-script: my-script.sh # optional, runs the specified script after succesful deployment, using `bash`. The deploy version is availabe as the VERSION variable inside the script
34+
post-deploy-command: ["./my-script.sh", "arg1", "arg2"] # optional, runs the specified command after succesful deployment. The deployed version is availabe as the $VERSION environment variable
3535
- id: my-container # in case of ECS, this is the service name
3636
type: ecs
3737
cluster: my-cluster

deployments/deploy.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/spf13/cobra"
88
"os"
99
"os/exec"
10+
"strings"
1011
"sync"
1112
)
1213

@@ -50,13 +51,13 @@ func doDeployment(deploymentConfig engine.Deployment) error {
5051
if err != nil {
5152
return err
5253
}
53-
if deploymentConfig.PostDeployScript() != "" {
54-
p("running post-deployment script %s...", deploymentConfig.PostDeployScript())
55-
bashPath, err := exec.LookPath("bash")
54+
if len(deploymentConfig.PostDeployCommand()) > 0 {
55+
commandString := strings.Join(deploymentConfig.PostDeployCommand(), " ")
56+
p("running post-deployment command %s...", commandString)
5657
if err != nil {
5758
return err
5859
}
59-
cmd := exec.Command(bashPath, deploymentConfig.PostDeployScript())
60+
cmd := exec.Command(deploymentConfig.PostDeployCommand()[0], deploymentConfig.PostDeployCommand()[1:]...)
6061
cmd.Env = os.Environ()
6162
cmd.Env = append(cmd.Env, "VERSION="+deploymentConfig.Version())
6263
output, err := cmd.Output()

engine/core.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ type Deployment interface {
1111
Id() string
1212
Type() string
1313
Version() string
14-
PostDeployScript() string
14+
PostDeployCommand() []string
1515
}
1616

1717
type BaseDeploymentConfig struct {
18-
Id_ string `mapstructure:"id"`
19-
Type_ string `mapstructure:"type"`
20-
Version_ string `mapstructure:"version"`
21-
PostDeployScript_ string `mapstructure:"post-deploy-script"`
18+
Id_ string `mapstructure:"id"`
19+
Type_ string `mapstructure:"type"`
20+
Version_ string `mapstructure:"version"`
21+
PostDeployCommand_ []string `mapstructure:"post-deploy-command"`
2222
}
2323

2424
func (d BaseDeploymentConfig) Id() string {
@@ -33,8 +33,8 @@ func (d BaseDeploymentConfig) Version() string {
3333
return d.Version_
3434
}
3535

36-
func (d BaseDeploymentConfig) PostDeployScript() string {
37-
return d.PostDeployScript_
36+
func (d BaseDeploymentConfig) PostDeployCommand() []string {
37+
return d.PostDeployCommand_
3838
}
3939

4040
type DeploymentEngine interface {

0 commit comments

Comments
 (0)