Skip to content

Commit 0a0bffe

Browse files
committed
python change
1 parent 19343cb commit 0a0bffe

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

docs/deploy_mkdocs.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""
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
55
"""
66

77
import argparse
@@ -20,8 +20,8 @@ def run_command(cmd, check=True):
2020
print(result.stderr, file=sys.stderr)
2121
return result
2222

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"""
2525
# Environment-specific bucket configuration
2626
buckets = {
2727
"sandbox": "sandbox.docs", # Your current sandbox bucket
@@ -32,49 +32,58 @@ def deploy_flex_manual(environment, branch=None, aws_profile=None, flex_manual_p
3232
print(f"Error: Environment must be one of {list(buckets.keys())}")
3333
sys.exit(1)
3434
bucket = buckets[environment]
35+
3536
# Default branch based on environment
3637
if branch is None:
3738
branch = "edge"
39+
3840
# Check if we're in CI
3941
is_ci = os.getenv("CI") is not None
4042
if is_ci:
4143
print("Running in CI environment")
4244
elif aws_profile is None:
4345
print("Warning: AWS_PROFILE not set. Make sure you have AWS credentials configured.")
46+
4447
# 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.")
4952
sys.exit(1)
53+
5054
# Build S3 sync command
51-
s3_path = f"s3://{bucket}/{branch}/{flex_manual_prefix}/"
55+
s3_path = f"s3://{bucket}/{branch}/"
5256
cmd = [
5357
"aws", "s3", "sync",
54-
str(source_dir) + "/",
58+
str(source_path) + "/",
5559
s3_path,
5660
"--delete",
5761
"--acl", "public-read"
5862
]
63+
5964
# Add AWS profile if specified
6065
if aws_profile:
6166
cmd.extend(["--profile", aws_profile])
67+
6268
print(f"Deploying to {environment} environment:")
6369
print(f" Bucket: {bucket}")
6470
print(f" Branch: {branch}")
6571
print(f" S3 Path: {s3_path}")
72+
6673
try:
6774
run_command(cmd)
6875
print(f"✅ Successfully deployed to {environment}!")
76+
6977
# Print the URL where it's deployed
70-
url = f"https://{bucket}/{branch}/{flex_manual_prefix}/"
78+
url = f"https://{bucket}/{branch}/"
7179
print(f"📍 Deployed to: {url}")
80+
7281
except subprocess.CalledProcessError as e:
7382
print(f"❌ Deployment failed with exit code {e.returncode}")
7483
sys.exit(1)
7584

7685
def main():
77-
parser = argparse.ArgumentParser(description="Deploy Flex Manual to S3")
86+
parser = argparse.ArgumentParser(description="Deploy Docs to S3")
7887
parser.add_argument(
7988
"environment",
8089
choices=["sandbox", "staging", "production"],
@@ -89,17 +98,19 @@ def main():
8998
help="AWS profile to use (defaults to AWS_PROFILE env var)"
9099
)
91100
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)"
95104
)
105+
96106
args = parser.parse_args()
97107
aws_profile = args.aws_profile or os.getenv("AWS_PROFILE")
98-
deploy_flex_manual(
108+
109+
deploy_docs(
99110
environment=args.environment,
100111
branch=args.branch,
101112
aws_profile=aws_profile,
102-
flex_manual_prefix=args.flex_manual_prefix
113+
source_dir=args.source_dir
103114
)
104115

105116
if __name__ == "__main__":

0 commit comments

Comments
 (0)