From 71364e94ea05eff80a4daac507bf826e86227ea9 Mon Sep 17 00:00:00 2001 From: Alvin Huang Date: Thu, 4 Apr 2019 18:53:30 -0400 Subject: [PATCH 1/4] add link checking script --- website/scripts/link-check.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 website/scripts/link-check.sh diff --git a/website/scripts/link-check.sh b/website/scripts/link-check.sh new file mode 100755 index 0000000000..3073324c3b --- /dev/null +++ b/website/scripts/link-check.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -xe + +# Install netlify-cli +sudo npm install netlify-cli -g + +# Deploy site to netlify +# Assumes NETLIFY_SITE_ID and NETLIFY_AUTH_TOKEN env variables are set +output=$(netlify deploy --dir=./website/build) + +# Grab deploy URL +url=$(echo "$output" | grep "Live Draft URL" | sed -E 's/.*(https:\/\/.*$)/\1/') + +# Checks broken links +wget \ + --delete-after \ + --level inf \ + --no-verbose \ + --recursive \ + --no-directories \ + --no-host-directories \ + --page-requisites \ + --spider \ + $url From 3e54ae4d19080b9b798bbfdab83eba61753f3fcb Mon Sep 17 00:00:00 2001 From: Alvin Huang Date: Thu, 4 Apr 2019 18:53:44 -0400 Subject: [PATCH 2/4] add netlify redirects --- website/config.rb | 3 +++ website/source/netlify-redirects | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 website/source/netlify-redirects diff --git a/website/config.rb b/website/config.rb index 7d0020a02a..de0d2aaeee 100644 --- a/website/config.rb +++ b/website/config.rb @@ -6,6 +6,9 @@ activate :hashicorp do |h| h.github_slug = "hashicorp/consul" end +# Netlify redirects/headers +proxy '_redirects', 'netlify-redirects', ignore: true + helpers do # Returns a segment tracking ID such that local development is not # tracked to production systems. diff --git a/website/source/netlify-redirects b/website/source/netlify-redirects new file mode 100644 index 0000000000..374ea9f3df --- /dev/null +++ b/website/source/netlify-redirects @@ -0,0 +1,22 @@ +# Consul Redirects +/api.html /api/index.html +/api/acl.html /api/acl/acl.html +/docs/agent/acl-rules.html /docs/acl/acl-rules.html +/docs/agent/acl-system.html /docs/acl/acl-system.html +/docs/agent/http.html /api/index.html +/docs/guides/acl-legacy.html /docs/acl/acl-legacy.html +/docs/guides/acl-migrate-acl-tokens.html /docs/acl/acl-migrate-acl-tokens.html +/docs/guides/bootstrapping.html /docs/install/bootstrapping.html +/docs/guides/sentinel.html /docs/agent/sentinel.html + +# Consul Learn Redirects +/docs/guides/acl.html https://learn.hashicorp.com/consul/advanced/day-1-operations/acl-guide +/docs/guides/agent-encryption.html https://learn.hashicorp.com/consul/advanced/day-1-operations/agent-encryption +/docs/guides/autopilot.html https://learn.hashicorp.com/consul/day-2-operations/advanced-operations/autopilot +/docs/guides/backup.html https://learn.hashicorp.com/consul/advanced/day-1-operations/backup +/docs/guides/cluster-monitoring-metrics.html https://learn.hashicorp.com/consul/advanced/day-1-operations/monitoring +/docs/guides/creating-certificates.html https://learn.hashicorp.com/consul/advanced/day-1-operations/certificates +/docs/guides/deployment-guide.html https://learn.hashicorp.com/consul/advanced/day-1-operations/deployment-guide +/docs/guides/deployment.html https://learn.hashicorp.com/consul/advanced/day-1-operations/reference-architecture +/docs/guides/dns-cache.html https://learn.hashicorp.com/consul/day-2-operations/advanced-operations/dns-caching +/docs/guides/minikube.html https://learn.hashicorp.com/consul/getting-started-k8s/minikube From a05363161d52a17862bf20c979b4739e78900a44 Mon Sep 17 00:00:00 2001 From: Alvin Huang Date: Thu, 4 Apr 2019 18:54:47 -0400 Subject: [PATCH 3/4] add link checking to CI and split website build/deploy --- .circleci/config.yml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23ba19f285..8de48c6407 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -182,10 +182,39 @@ jobs: name: middleman build command: bundle exec middleman build + # saves website build directory + - persist_to_workspace: + root: . + paths: + - build + + deploy-website: + # setting the working_directory along with the checkout path allows us to not have + # to cd into the website/ directory for commands + working_directory: ~/project/website + docker: + - image: *MIDDLEMAN_IMAGE + steps: + - checkout: + path: ~/project + # attach website build directory + - attach_workspace: + at: ~/project/website - run: name: website deploy command: ./scripts/deploy.sh + # Link check on a temporary netlify deployed site + docs-link-checker: + docker: + - image: circleci/node:lts + steps: + - checkout + # attach website build directory + - attach_workspace: + at: ~/project/website + - run: ./website/scripts/link-check.sh + # build frontend yarn cache frontend-cache: docker: @@ -267,7 +296,13 @@ workflows: - dev-build website: jobs: - - build-website: + - build-website + - docs-link-checker: + requires: + - build-website + - deploy-website: + requires: + - docs-link-checker context: static-sites filters: branches: From 172652a7cba9134116fff0828e833ada58b8dbde Mon Sep 17 00:00:00 2001 From: Alvin Huang Date: Fri, 5 Apr 2019 10:38:27 -0400 Subject: [PATCH 4/4] link check only on non-forks --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8de48c6407..d74eda7806 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -300,6 +300,10 @@ workflows: - docs-link-checker: requires: - build-website + filters: + branches: + ignore: + - /^pull\/.*$/ # only run link checker on non forks - deploy-website: requires: - docs-link-checker