Skip to content

Commit 4f0c2cd

Browse files
authored
[INFRANG-7812] implement deploy-apps command to support slingshot deploys (#191)
* implement deploy-apps command to support slingshot deploys * bump version * address PR feedback * remove reference to values.yaml
1 parent 0675bd8 commit 4f0c2cd

10 files changed

Lines changed: 395 additions & 38 deletions

File tree

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
v1.5.4
2-
Temporarily disable Go version checks
1+
v1.6.0
2+
Add new deploy-apps command
33

44
Previously:
5+
- Temporarily disable Go version checks
56
- Push Docker images to one ECR region
67
- add option to pass branch name and dryRun to catalog-sync
7-
- add shared workflow for Claude actions

cmd/goci/README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,42 @@ go build -o ./bin/goci ./cmd/goci
4242

4343
cp ./bin/goci ./testApp
4444

45-
cd testApp && goci
45+
cd testApp && ./goci validate
4646
```
47+
48+
Running goci fully locally is awkward: most behavior depends on Clever CI **contexts and environment variables** (AWS, Catapult, etc.). For realistic validation, prefer testing **in CircleCI** using the orb parameter below.
49+
50+
### Testing a goci branch in CircleCI (`build_goci_from_branch`)
51+
52+
The [circleci-orbs](https://github.com/Clever/circleci-orbs) jobs that invoke goci accept an optional parameter **`build_goci_from_branch`**. When set to a **branch name on this repo (`ci-scripts`)**, the job clones that branch and runs `go install ./cmd/goci` instead of installing the latest released goci binary.
53+
54+
**Steps**
55+
56+
1. **Push your goci changes** to a branch of `github.com/Clever/ci-scripts`
57+
2. **Pick a test application** whose `.circleci/config.yml` already uses `clever/circleci-orbs`
58+
3. **Set `build_goci_from_branch`** on each orb job that should use your in-development goci, using the ci-scripts branch name:
59+
60+
```yaml
61+
- circleci-orbs/build_publish_deploy:
62+
name: build_publish_deploy
63+
working_directory: ~/project
64+
build_goci_from_branch: YOUR_CI_SCRIPTS_BRANCH
65+
# ... contexts, requires, etc.
66+
- circleci-orbs/deploy_apps:
67+
name: deploy_apps
68+
working_directory: ~/project
69+
build_goci_from_branch: YOUR_CI_SCRIPTS_BRANCH
70+
requires:
71+
- build_publish_deploy
72+
# ... contexts, filters, etc.
73+
```
74+
75+
4. **If you also changed the orb YAML or scripts**, publish or reference a **dev** orb version from your `circleci-orbs` branch (for example `clever/circleci-orbs@dev:<git-sha>`) so the pipeline runs your updated job definitions, not only a new goci binary.
76+
77+
**Jobs that support `build_goci_from_branch`**
78+
79+
| Job | What it runs |
80+
| --- | --- |
81+
| `build_publish_deploy` | `goci artifact-build-publish-deploy` |
82+
| `deploy_apps` | goci in deploy-apps mode (after artifacts exist) |
83+
| `publish_utility` | goci `publish-utility` flow |

cmd/goci/main.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import (
1616
"github.com/Clever/ci-scripts/internal/environment"
1717
"github.com/Clever/ci-scripts/internal/lambda"
1818
"github.com/Clever/ci-scripts/internal/repo"
19+
"github.com/Clever/ci-scripts/internal/slingshot"
1920
ciIntegrationsModels "github.com/Clever/circle-ci-integrations/gen-go/models"
2021
)
2122

22-
const usage = "usage: goci <validate|detect|artifact-build-publish-deploy|publish-utility>"
23+
const usage = "usage: goci <validate|detect|artifact-build-publish-deploy|publish-utility|deploy-apps>"
2324

2425
// This app assumes the code has been checked out and that the
2526
// repository is the working directory.
@@ -56,7 +57,7 @@ func run(mode string) error {
5657
var err error
5758

5859
// Only discover applications for specific modes
59-
if mode == "validate" || mode == "detect" || mode == "artifact-build-publish-deploy" {
60+
if mode == "validate" || mode == "detect" || mode == "artifact-build-publish-deploy" || mode == "deploy-apps" {
6061
apps, err = repo.DiscoverApplications("./launch")
6162
if err != nil {
6263
return err
@@ -79,6 +80,8 @@ func run(mode string) error {
7980
case "detect":
8081
fmt.Println(strings.Join(appIDs, " "))
8182
return nil
83+
case "deploy-apps":
84+
return deployApps(appIDs)
8285
case "artifact-build-publish-deploy":
8386
// continue
8487
default:
@@ -295,3 +298,19 @@ func publishUtility() error {
295298
return nil
296299

297300
}
301+
302+
func deployApps(appIds []string) error {
303+
if len(appIds) == 0 {
304+
fmt.Println("No applications have buildable changes. If this is unexpected, " +
305+
"double check your artifact dependency configuration in the launch yaml.")
306+
return nil
307+
}
308+
ctx := context.Background()
309+
310+
if environment.Branch() == "master" {
311+
if err := slingshot.New().DeployApps(ctx, appIds); err != nil {
312+
return err
313+
}
314+
}
315+
return validateRun()
316+
}

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ require (
66
github.com/Clever/catapult/gen-go/models v1.206.0
77
github.com/Clever/circle-ci-integrations/gen-go/client v0.14.0
88
github.com/Clever/circle-ci-integrations/gen-go/models v0.14.0
9+
github.com/Clever/slingshot/gen-go/client v1.1.0
10+
github.com/Clever/slingshot/gen-go/models v1.1.0
911
github.com/Clever/wag/logging/wagclientlogger v0.0.0-20250514163731-344287ef8d81
1012
github.com/aws/aws-sdk-go-v2 v1.36.5
1113
github.com/aws/aws-sdk-go-v2/config v1.29.17

0 commit comments

Comments
 (0)