Skip to content

Commit

Permalink
Added PDF redirects to CircleCI build process (#1565)
Browse files Browse the repository at this point in the history
Added PDF redirects to CircleCI build process
  • Loading branch information
rrelledge authored Oct 5, 2021
1 parent 4d5d35b commit 9d8f2aa
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions utilities/redirect_pdfs/add_pdf_redirects.sh
Original file line number Diff line number Diff line change
@@ -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."
10 changes: 10 additions & 0 deletions utilities/redirect_pdfs/pdf_redirects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Condition": {
"KeyPrefixEquals": "latest/pdf-gen-"
},
"Redirect": {
"HostName": "docs.redis.com",
"Protocol": "https",
"ReplaceKeyWith": "latest/"
}
},
11 changes: 11 additions & 0 deletions website.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
}

]
Expand Down

0 comments on commit 9d8f2aa

Please sign in to comment.