Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add GitHub action to upload S3 website configuration #10612

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

StefanScherer
Copy link
Member

@StefanScherer StefanScherer commented Apr 9, 2020

Add a GitHub action to upload the S3 website configuration from a JSON file in this repo.
With that PR it's possible to maintain the redirections directly from this repo by making pull requests to

An example for the docs-stage.docker.com site with a redirect of all v17.03/ to /
Important keys are

  • KeyPrefixEquals is set to v17.03/
  • ReplaceKeyPrefixWith is set to empty string "" which means /
  • HostName and Protocol must be set for each redirect rule, otherwise AWS redirects to the internal name. That's why we need two different JSON files.
  {
   "Condition": {
    "HttpErrorCodeReturnedEquals": null,
    "KeyPrefixEquals": "v17.03/"
   },
   "Redirect": {
    "HostName": "docs-stage.docker.com",
    "HttpRedirectCode": null,
    "Protocol": "https",
    "ReplaceKeyPrefixWith": "",
    "ReplaceKeyWith": null
   }
  },

Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
@StefanScherer
Copy link
Member Author

A temporary build that also ran in this PR branch was green: https://github.com/docker/docker.github.io/pull/10612/checks?check_run_id=573354449 and it successfully uploaded the website config for docs-stage.

@StefanScherer
Copy link
Member Author

Ping @thaJeztah this is the replacement for the nginx redirect rules we had in the past. Now a similar config for S3 website is back in the repo to maintain it through PRs.

@thaJeztah
Copy link
Member

Thanks! I just recalled we also need to take redirect_from entries in the /ee and /datacenter into account before we remove the content; here's a quick 'n dirty way to get which pages have redirects from outside of /(ee|datacenter|compliance);

echo "{" > extra-redirects.json
grep -E ': "/(compliance|datacenter|ee)/' <(curl -fsSL https://docs.docker.com/redirects.json | jq .) >> extra-redirects.json
echo '  "/dummy/": "/"' >> extra-redirects.json
echo "}" >> extra-redirects.json

extra-redirects.json.txt

@thaJeztah
Copy link
Member

For those pages, I think we'd need dummy pages in /ee, /datacenter and /compliance

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StefanScherer
Copy link
Member Author

This PR only adds automation to the current status. I've uploaded the website configs manually with a similar Go tool, there's no aws cli command for that.

For the three EE related folders I plan to do this in a new PR after the merge. We can simply remove the three folders and add three redirection rules to the new website*.json files. We will test this PR in docs-stage to see if everything gets a new URL prefix with the target domain name.

@StefanScherer StefanScherer merged commit 9e14ea5 into master Apr 9, 2020
@StefanScherer StefanScherer deleted the add-redirect-rules branch April 9, 2020 11:06
@thaJeztah
Copy link
Member

We can simply remove the three folders and add three redirection rules to the new

Right, so that's the tricky bit; there's redirects that are currently in place that redirect to the /ee or /datacenter directory, but due to how Jekyll constructs redirects, those redirects are configured in the target page.

For example, https://docs.docker.com/reference/ucp/3.0/cli/support/ redirects to https://docs.docker.com/datacenter/ucp/3.0/reference/cli/support/

That redirect is defined in https://github.com/docker/docker.github.io/blame/663ea14a3ca321d8f4a257d3b5ca8648ba5aec2d/datacenter/ucp/3.0/reference/cli/support.md#L6

Which means that once that page is removed, the redirect is no longer in place. So for pages that define a redirect, we should either replace them with a "dummy" page that only has the redirect_from page set (so that Jekyll generates the redirect page), or commit the generated redirect HTML's to git

@thaJeztah
Copy link
Member

Updated, with redirect "from" /ee/ and /datacenter/ removed

extra-redirects.json.txt

@StefanScherer
Copy link
Member Author

I don't know how much effort we want to put into the forwarding to Mirantis. Do we have an "SLA" of how many of the old links should work/redirect to them? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants