diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 917e5ce2cdb7..4c2f65d6df42 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -46,7 +46,6 @@ jobs: DOCS_S3_CONFIG="s3-config.json" DOCS_CLOUDFRONT_ID="E1MYDYF65FW3HG" DOCS_LAMBDA_FUNCTION_REDIRECTS="DockerDocsRedirectFunction-labs" - DOCS_SLACK_MSG="Successfully deployed docs-labs from lab branch. $DOCS_URL" else echo >&2 "ERROR: unknown branch ${{ github.ref }}" exit 1 diff --git a/_releaser/cloudfront-lambda-redirects.js b/_releaser/cloudfront-lambda-redirects.js index face10fe003c..de8c59d34300 100644 --- a/_releaser/cloudfront-lambda-redirects.js +++ b/_releaser/cloudfront-lambda-redirects.js @@ -25,10 +25,16 @@ exports.handler = (event, context, callback) => { } const redirectsPrefixes = JSON.parse(`{{.RedirectsPrefixesJSON}}`); - for (let key in redirectsPrefixes) { - if (!request.uri.startsWith(key)) { + for (let x in redirectsPrefixes) { + const rp = redirectsPrefixes[x]; + if (!request.uri.startsWith(`/${rp['prefix']}`)) { continue; } + let newlocation = "/"; + if (rp['strip']) { + let re = new RegExp(`(^/${rp['prefix']})`, 'gi'); + newlocation = request.uri.replace(re,'/'); + } //console.log(`redirect: ${request.uri} to ${redirectsPrefixes[key]}`); const response = { status: '301', @@ -36,7 +42,7 @@ exports.handler = (event, context, callback) => { headers: { location: [{ key: 'Location', - value: redirectsPrefixes[key], + value: newlocation, }], }, } diff --git a/_releaser/redirects-prefixes.json b/_releaser/redirects-prefixes.json index a032ff2de9ef..978000601a6b 100644 --- a/_releaser/redirects-prefixes.json +++ b/_releaser/redirects-prefixes.json @@ -1,21 +1,90 @@ -{ - "/compliance/": "/", - "/datacenter/": "/", - "/ee/": "/", - "/v1.4/": "/", - "/v1.5/": "/", - "/v1.6/": "/", - "/v1.7/": "/", - "/v1.8/": "/", - "/v1.9/": "/", - "/v1.10/": "/", - "/v1.11/": "/", - "/v1.12/": "/", - "/v1.13/": "/", - "/v17.03/": "/", - "/v17.06/": "/", - "/v17.09/": "/", - "/v17.12/": "/", - "/v18.03/": "/", - "/v18.09/": "/" -} +[ + { + "prefix": "compliance/", + "strip": false + }, + { + "prefix": "datacenter/", + "strip": false + }, + { + "prefix": "ee/", + "strip": false + }, + { + "prefix": "v1.4/", + "strip": true + }, + { + "prefix": "v1.5/", + "strip": true + }, + { + "prefix": "v1.6/", + "strip": true + }, + { + "prefix": "v1.7/", + "strip": true + }, + { + "prefix": "v1.8/", + "strip": true + }, + { + "prefix": "v1.9/", + "strip": true + }, + { + "prefix": "v1.10/", + "strip": true + }, + { + "prefix": "v1.11/", + "strip": true + }, + { + "prefix": "v1.12/", + "strip": true + }, + { + "prefix": "v1.13/", + "strip": true + }, + { + "prefix": "v17.03/", + "strip": true + }, + { + "prefix": "v17.06/enterprise/", + "strip": false + }, + { + "prefix": "v17.06/", + "strip": true + }, + { + "prefix": "v17.09/", + "strip": true + }, + { + "prefix": "v17.12/", + "strip": true + }, + { + "prefix": "v18.03/ee/", + "strip": false + }, + { + "prefix": "v18.03/", + "strip": true + }, + { + "prefix": "v18.09/ee/", + "strip": false + }, + { + "prefix": "v18.09/", + "strip": true + } +]