From b6508e54da2edb67f6b5fccb1a529d6422cee175 Mon Sep 17 00:00:00 2001 From: mikemckiernan Date: Tue, 5 Apr 2022 16:01:24 -0400 Subject: [PATCH] docs: Add redirect page (#64) We need an `index.html` file in the root of the repo on the `gh-pages` branch. This way, if a customer ends up at `.../core`, we can redirect to `.../core/main` so our customer does not receive a 404. Co-authored-by: Karl Higley --- .github/workflows/docs-sched-rebuild.yaml | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/docs-sched-rebuild.yaml b/.github/workflows/docs-sched-rebuild.yaml index d0c9112f7..b4339f3c3 100644 --- a/.github/workflows/docs-sched-rebuild.yaml +++ b/.github/workflows/docs-sched-rebuild.yaml @@ -72,6 +72,46 @@ jobs: echo "Git adding ${i}" git add "${i}" done + - name: Check or create dot-no-jekyll file + run: | + if [ -f ".nojekyll" ]; then + echo "The dot-no-jekyll file already exists." + exit 0 + fi + touch .nojekyll + git add .nojekyll + - name: Check or create redirect page + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + resp=$(grep 'http-equiv="refresh"' index.html 2>/dev/null) || true + if [ -n "${resp}" ]; then + echo "The redirect file already exists." + exit 0 + fi + # If any of these commands fail, fail the build. + def_branch=$(gh api "repos/${GITHUB_REPOSITORY}" --jq ".default_branch") + html_url=$(gh api "repos/${GITHUB_REPOSITORY}/pages" --jq ".html_url") + # Beware ugly quotation mark avoidance in the foll lines. + echo '' > index.html + echo '' >> index.html + echo ' ' >> index.html + echo ' Redirect to documentation' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo '

Please follow the link to the ' >> index.html + echo ${def_branch}' branch documentation.

' >> index.html + echo ' ' >> index.html + echo '' >> index.html + git add index.html - name: Commit changes to the GitHub Pages branch run: | git status