Skip to content

Commit d2172c8

Browse files
Merge pull request #249 from circleci/revert-delete-script
revert delete redirects script
2 parents 7832f89 + b73c049 commit d2172c8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

scripts/create-redirect.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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!"

0 commit comments

Comments
 (0)