diff --git a/.circleci/config.yml b/.circleci/config.yml index e6e99912548..cd95c06f733 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -375,6 +375,12 @@ jobs: steps: - attach_workspace: at: ~/project + # Create new_website.json to include PDF redirects + - run: + name: Create new_website.json to include PDF redirects + command: | + cd utilities/redirect_pdfs + ./add_pdf_redirects.sh # Set the signature version for the S3 auth - run: name: Setting Signature Version 4 for S3 Request Authentication @@ -397,6 +403,9 @@ jobs: # Sync standalone PDFs aws s3 sync public s3://docs.redis.com/$LOCATION --delete --acl public-read --metadata-directive REPLACE --exclude "*" --include "pdfs/*.pdf" --cache-control max-age=0 # --size-only + + # Update the S3 site configuration to include PDF redirects + aws s3api put-bucket-website --bucket docs.redis.com --website-configuration file://utilities/redirect_pdfs/new_website.json # Remove temporary helper files created for standalone PDF generation - run: name: Remove standalone PDF generation helper files diff --git a/utilities/redirect_pdfs/add_pdf_redirects.sh b/utilities/redirect_pdfs/add_pdf_redirects.sh new file mode 100755 index 00000000000..b7e1f14306b --- /dev/null +++ b/utilities/redirect_pdfs/add_pdf_redirects.sh @@ -0,0 +1,9 @@ +echo "Adding PDF redirects..." + +touch new_website.json + +awk "1;/RoutingRules/{exit}" ../../website.json >> new_website.json +cat pdf_redirects.json >> new_website.json +awk "p;/RoutingRules/{p=1}" ../../website.json >> new_website.json + +echo "Finished adding PDF redirects." diff --git a/utilities/redirect_pdfs/pdf_redirects.json b/utilities/redirect_pdfs/pdf_redirects.json new file mode 100644 index 00000000000..99b86144cb8 --- /dev/null +++ b/utilities/redirect_pdfs/pdf_redirects.json @@ -0,0 +1,10 @@ + { + "Condition": { + "KeyPrefixEquals": "latest/pdf-gen-" + }, + "Redirect": { + "HostName": "docs.redis.com", + "Protocol": "https", + "ReplaceKeyWith": "latest/" + } + }, diff --git a/website.json b/website.json index 15fe3141e3e..1dec12f8835 100644 --- a/website.json +++ b/website.json @@ -235,6 +235,17 @@ "Protocol": "https", "ReplaceKeyPrefixWith": "latest/rc/how-to/creating-iam-resources/creating-aws-user-redis-enterprise-vpc/" } + }, + { + "Condition": { + "KeyPrefixEquals": "latest/pdfs/", + "HttpErrorCodeReturnedEquals": "403" + }, + "Redirect": { + "HostName": "docs.redis.com", + "Protocol": "https", + "ReplaceKeyWith": "latest/" + } } ]