diff --git a/_layouts/redirect.html b/_layouts/redirect.html index 949977a..de02649 100644 --- a/_layouts/redirect.html +++ b/_layouts/redirect.html @@ -1,5 +1,5 @@ -{% assign absolute_target = page.target | absolute_url %} +{% assign absolute_target = page.target | replace: '$$LATEST_RELEASE$$', site.data.kroxylicious.latestRelease | absolute_url %} diff --git a/build.sh b/build.sh index 95484c3..eaa6276 100755 --- a/build.sh +++ b/build.sh @@ -34,3 +34,4 @@ BUILD_COMMAND='eval "$(rbenv init -)" && cp -r /css/_sass/bootstrap /site/_sass/ RUN_ARGS+=(bash -c "${BUILD_COMMAND}") echo "${RUN_ARGS[@]}" ${CONTAINER_ENGINE} run "${RUN_ARGS[@]}" +./test.sh diff --git a/get-started.markdown b/get-started.markdown new file mode 100644 index 0000000..bc243d7 --- /dev/null +++ b/get-started.markdown @@ -0,0 +1,5 @@ +--- +layout: redirect +target: "/documentation/$$LATEST_RELEASE$$/html/proxy-quick-start/" +delay: 1 +--- diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..99e4276 --- /dev/null +++ b/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Checks the output of build.sh (which is the production build deployed to pages) +set -euo pipefail + +LATEST_RELEASE=$(grep "latestRelease:" _data/kroxylicious.yml | awk '{print $2}') + +LATEST_RELEASE_QUICKSTART="_site/documentation/${LATEST_RELEASE}/html/proxy-quick-start/index.html" +PERMANENT_QUICKSTART_REDIRECT="_site/get-started.html" +EXPECTED_REDIRECT_STRING="" + +check_file_exists() { + local file_path="$1" + local file_description="$2" + if [ -f "${file_path}" ]; then + echo "SUCCESS: ${file_description} file found at ${file_path}" + else + echo "ERROR: ${file_description} file not found at ${file_path}" >&2 + exit 1 + fi +} + +echo "Expect /get-started to HTML redirect to the latest quickstart" +check_file_exists "${LATEST_RELEASE_QUICKSTART}" "Latest release quickstart" +check_file_exists "${PERMANENT_QUICKSTART_REDIRECT}" "Permanent quickstart redirect" + +if grep -qF "${EXPECTED_REDIRECT_STRING}" "${PERMANENT_QUICKSTART_REDIRECT}"; then + echo "SUCCESS: Expected redirect string found in ${PERMANENT_QUICKSTART_REDIRECT}" +else + echo "ERROR: Expected redirect string '${EXPECTED_REDIRECT_STRING}' not found in ${PERMANENT_QUICKSTART_REDIRECT}" + exit 1 +fi +echo "All checks succeeded!" +exit 0