Skip to content

Commit c0e3af3

Browse files
authored
configure allowed deploy branches (#193)
* configure allowed deploy branches * bump versions
1 parent 4f0c2cd commit c0e3af3

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
v1.6.0
2-
Add new deploy-apps command
1+
v1.7.0
2+
Support configurable deployment branches
33

44
Previously:
5+
- Add new deploy-apps command
56
- Temporarily disable Go version checks
67
- Push Docker images to one ECR region
7-
- add option to pass branch name and dryRun to catalog-sync

cmd/goci/main.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,26 @@ func deployApps(appIds []string) error {
307307
}
308308
ctx := context.Background()
309309

310-
if environment.Branch() == "master" {
310+
if shouldDeploy() {
311311
if err := slingshot.New().DeployApps(ctx, appIds); err != nil {
312312
return err
313313
}
314314
}
315315
return validateRun()
316316
}
317+
318+
func shouldDeploy() bool {
319+
allowedBranches := os.Getenv("DEPLOY_BRANCHES")
320+
if allowedBranches == "" {
321+
allowedBranches = "master"
322+
}
323+
324+
currentBranch := environment.Branch()
325+
branches := strings.Split(allowedBranches, ",")
326+
for _, branch := range branches {
327+
if strings.TrimSpace(branch) == currentBranch {
328+
return true
329+
}
330+
}
331+
return false
332+
}

0 commit comments

Comments
 (0)