1
1
#!/usr/bin/env python3
2
2
"""
3
- Deploy Flex Manual to S3
4
- Replaces the deploy-flex-manual Makefile target with staging/production/sandbox support
3
+ Deploy Docs to S3
4
+ Replaces the deploy Makefile target with staging/production/sandbox support
5
5
"""
6
6
7
7
import argparse
@@ -20,8 +20,8 @@ def run_command(cmd, check=True):
20
20
print (result .stderr , file = sys .stderr )
21
21
return result
22
22
23
- def deploy_flex_manual (environment , branch = None , aws_profile = None , flex_manual_prefix = "flex-manual " ):
24
- """Deploy flex manual to S3"""
23
+ def deploy_docs (environment , branch = None , aws_profile = None , source_dir = "site " ):
24
+ """Deploy docs to S3"""
25
25
# Environment-specific bucket configuration
26
26
buckets = {
27
27
"sandbox" : "sandbox.docs" , # Your current sandbox bucket
@@ -32,49 +32,58 @@ def deploy_flex_manual(environment, branch=None, aws_profile=None, flex_manual_p
32
32
print (f"Error: Environment must be one of { list (buckets .keys ())} " )
33
33
sys .exit (1 )
34
34
bucket = buckets [environment ]
35
+
35
36
# Default branch based on environment
36
37
if branch is None :
37
38
branch = "edge"
39
+
38
40
# Check if we're in CI
39
41
is_ci = os .getenv ("CI" ) is not None
40
42
if is_ci :
41
43
print ("Running in CI environment" )
42
44
elif aws_profile is None :
43
45
print ("Warning: AWS_PROFILE not set. Make sure you have AWS credentials configured." )
46
+
44
47
# Verify source directory exists
45
- source_dir = Path (flex_manual_prefix ) / "site"
46
- if not source_dir .exists ():
47
- print (f"Error: Source directory { source_dir } does not exist." )
48
- print ("Make sure you've run 'make build-flex-manual ' first." )
48
+ source_path = Path (source_dir )
49
+ if not source_path .exists ():
50
+ print (f"Error: Source directory { source_path } does not exist." )
51
+ print ("Make sure you've run 'make build' first." )
49
52
sys .exit (1 )
53
+
50
54
# Build S3 sync command
51
- s3_path = f"s3://{ bucket } /{ branch } /{ flex_manual_prefix } / "
55
+ s3_path = f"s3://{ bucket } /{ branch } /"
52
56
cmd = [
53
57
"aws" , "s3" , "sync" ,
54
- str (source_dir ) + "/" ,
58
+ str (source_path ) + "/" ,
55
59
s3_path ,
56
60
"--delete" ,
57
61
"--acl" , "public-read"
58
62
]
63
+
59
64
# Add AWS profile if specified
60
65
if aws_profile :
61
66
cmd .extend (["--profile" , aws_profile ])
67
+
62
68
print (f"Deploying to { environment } environment:" )
63
69
print (f" Bucket: { bucket } " )
64
70
print (f" Branch: { branch } " )
65
71
print (f" S3 Path: { s3_path } " )
72
+
66
73
try :
67
74
run_command (cmd )
68
75
print (f"✅ Successfully deployed to { environment } !" )
76
+
69
77
# Print the URL where it's deployed
70
- url = f"https://{ bucket } /{ branch } /{ flex_manual_prefix } / "
78
+ url = f"https://{ bucket } /{ branch } /"
71
79
print (f"📍 Deployed to: { url } " )
80
+
72
81
except subprocess .CalledProcessError as e :
73
82
print (f"❌ Deployment failed with exit code { e .returncode } " )
74
83
sys .exit (1 )
75
84
76
85
def main ():
77
- parser = argparse .ArgumentParser (description = "Deploy Flex Manual to S3" )
86
+ parser = argparse .ArgumentParser (description = "Deploy Docs to S3" )
78
87
parser .add_argument (
79
88
"environment" ,
80
89
choices = ["sandbox" , "staging" , "production" ],
@@ -89,17 +98,19 @@ def main():
89
98
help = "AWS profile to use (defaults to AWS_PROFILE env var)"
90
99
)
91
100
parser .add_argument (
92
- "--flex-manual-prefix " ,
93
- default = "flex-manual " ,
94
- help = "Flex manual prefix directory (default: flex-manual )"
101
+ "--source-dir " ,
102
+ default = "site " ,
103
+ help = "Source directory to deploy (default: site )"
95
104
)
105
+
96
106
args = parser .parse_args ()
97
107
aws_profile = args .aws_profile or os .getenv ("AWS_PROFILE" )
98
- deploy_flex_manual (
108
+
109
+ deploy_docs (
99
110
environment = args .environment ,
100
111
branch = args .branch ,
101
112
aws_profile = aws_profile ,
102
- flex_manual_prefix = args .flex_manual_prefix
113
+ source_dir = args .source_dir
103
114
)
104
115
105
116
if __name__ == "__main__" :
0 commit comments