File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ # Validate parameters
5
+ if [ " $# " -ne 3 ]; then
6
+ echo " Usage: $0 <bucket_name> <old_path> <new_path>"
7
+ echo " Example: $0 circleci-docs-platform-assets /about-circleci/ /docs-preview/guides/about-circleci/index.html"
8
+ exit 1
9
+ fi
10
+
11
+ DESTINATION_FOLDER=" docs-preview"
12
+
13
+ BUCKET_NAME=" $1 "
14
+ OLD_PATH=" $2 " # must include leading and trailing slash e.g. /about-circleci/
15
+ NEW_PATH=" /${DESTINATION_FOLDER} $3 " # full target path e.g. /docs-preview/guide/about-circleci/index.html
16
+
17
+ echo " [INFO] Deploying redirect to bucket: s3://$BUCKET_NAME "
18
+ echo " [INFO] Redirect: $OLD_PATH -> $NEW_PATH "
19
+
20
+ # Convert old path to S3 key (no leading slash before key!)
21
+ S3_KEY=" ${DESTINATION_FOLDER}${OLD_PATH} index.html"
22
+
23
+ echo " [INFO] Creating S3 object: $S3_KEY "
24
+
25
+ # Create the redirect object in S3
26
+ aws s3api put-object \
27
+ --bucket " $BUCKET_NAME " \
28
+ --key " $S3_KEY " \
29
+ --website-redirect-location " $NEW_PATH " \
30
+ --content-type " text/html" \
31
+ --content-length " 0"
32
+
33
+ echo " [INFO] ✅ Redirect created successfully!"
You can’t perform that action at this time.
0 commit comments