Skip to content

Commit 0e57fc8

Browse files
committed
Minor adjustments to promoter script and CI configuration
1 parent db81479 commit 0e57fc8

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,10 @@ jobs:
279279
fi
280280
fi
281281
282-
# Deploy to staging for release branches, regular deploy for others
283-
if [[ "$GITHUB_REF" == "refs/heads/beta" || "$GITHUB_REF" == "refs/heads/release" || "$GITHUB_REF" =~ ^refs/heads/LTS ]]; then
284-
echo "Deploying to staging directory for release branch: $GITHUB_REF"
285-
DEPLOY_TO_STAGING=true state run deploy-updates
286-
DEPLOY_TO_STAGING=true state run deploy-installers
287-
DEPLOY_TO_STAGING=true state run deploy-remote-installer
288-
else
289-
echo "Deploying normally for non-release branch: $GITHUB_REF"
290-
state run deploy-updates
291-
state run deploy-installers
292-
state run deploy-remote-installer
293-
fi
282+
echo "Deploying for integration tests"
283+
state run deploy-updates
284+
state run deploy-installers
285+
state run deploy-remote-installer
294286
295287
- # === Integration Tests ===
296288
name: Integration Tests

scripts/ci/s3-promoter/main.go

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,52 @@ import (
1616
"github.com/ActiveState/cli/internal/condition"
1717
)
1818

19-
var awsRegionName, awsBucketName string
19+
var awsRegionName, awsBucketName, basePrefix string
2020
var client *s3.Client
2121

2222
func main() {
2323
if !condition.InUnitTest() {
24-
if len(os.Args) != 3 {
25-
log.Fatalf("Usage: %s <region-name> <bucket-name>", os.Args[0])
24+
if len(os.Args) != 3 && len(os.Args) != 4 {
25+
log.Fatalf("Usage: %s <region-name> <bucket-name> [base-prefix]", os.Args[0])
2626
}
2727

2828
awsRegionName = os.Args[1]
2929
awsBucketName = os.Args[2]
30+
if len(os.Args) == 4 {
31+
basePrefix = os.Args[3]
32+
if basePrefix != "" && !strings.HasSuffix(basePrefix, "/") {
33+
basePrefix += "/"
34+
}
35+
}
3036

3137
run()
3238
}
3339
}
3440

3541
func run() {
3642
fmt.Printf("Promoting staging files to production in bucket: %s\n", awsBucketName)
43+
if basePrefix != "" {
44+
fmt.Printf("Using base prefix: %s\n", basePrefix)
45+
}
3746

3847
createClient()
3948

40-
// List all objects with staging/ prefix
41-
stagingObjects, err := listObjectsWithPrefix("staging/")
49+
// List all objects with <basePrefix>staging/ prefix
50+
allObjects, err := listObjectsWithPrefix(basePrefix + "staging/")
4251
if err != nil {
4352
log.Fatalf("Failed to list staging objects: %v", err)
4453
}
4554

55+
// Filter out the root staging directory itself (but keep subdirectories)
56+
var stagingObjects []types.Object
57+
stagingPrefix := basePrefix + "staging/"
58+
for _, obj := range allObjects {
59+
if *obj.Key == stagingPrefix {
60+
continue
61+
}
62+
stagingObjects = append(stagingObjects, obj)
63+
}
64+
4665
if len(stagingObjects) == 0 {
4766
fmt.Println("No staging files found to promote.")
4867
return
@@ -56,13 +75,14 @@ func run() {
5675
// Copy each staging object to production location and delete the staging version
5776
for _, obj := range stagingObjects {
5877
stagingKey := *obj.Key
59-
productionKey := strings.TrimPrefix(stagingKey, "staging/")
78+
relativeKey := strings.TrimPrefix(stagingKey, basePrefix+"staging/")
79+
destinationKey := basePrefix + "release/" + relativeKey
6080

61-
fmt.Printf("Promoting %s -> %s\n", stagingKey, productionKey)
81+
fmt.Printf("Promoting %s -> %s\n", stagingKey, destinationKey)
6282

63-
err := copyObject(stagingKey, productionKey)
83+
err := copyObject(stagingKey, destinationKey)
6484
if err != nil {
65-
log.Fatalf("Failed to copy %s to %s: %v", stagingKey, productionKey, err)
85+
log.Fatalf("Failed to copy %s to %s: %v", stagingKey, destinationKey, err)
6686
}
6787

6888
err = deleteObject(stagingKey)

0 commit comments

Comments
 (0)