From 5e9b4024ff2e483098eb05c9784d16d1cc0a93e9 Mon Sep 17 00:00:00 2001 From: Carlos Santana Date: Wed, 12 May 2021 16:09:47 -0400 Subject: [PATCH] add gh-action to deploy mkdocs to gh-pages (#3557) * add gh-action to deploy mkdocs to gh-pages * update commit user for gh-pages Signed-off-by: Carlos Santana * switch to fast livereload Signed-off-by: Carlos Santana --- .github/workflows/knative-mkdocs.yaml | 31 +++++++++++++++++++++++++++ hack/docker/Dockerfile | 2 ++ hack/docker/README.md | 19 ++++++++++++++++ hack/docker/build.sh | 8 +++++++ hack/docker/clean.sh | 8 +++++++ hack/docker/mkdocs.sh | 5 +++++ hack/docker/run.sh | 10 +++++++++ 7 files changed, 83 insertions(+) create mode 100644 .github/workflows/knative-mkdocs.yaml create mode 100644 hack/docker/Dockerfile create mode 100644 hack/docker/README.md create mode 100755 hack/docker/build.sh create mode 100755 hack/docker/clean.sh create mode 100755 hack/docker/mkdocs.sh create mode 100755 hack/docker/run.sh diff --git a/.github/workflows/knative-mkdocs.yaml b/.github/workflows/knative-mkdocs.yaml new file mode 100644 index 000000000..530ad041b --- /dev/null +++ b/.github/workflows/knative-mkdocs.yaml @@ -0,0 +1,31 @@ +name: Publish MkDocs + +on: + push: + branches: [ mkdocs ] + +jobs: + mkdocs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.9" + + - name: Install dependencies + run: | + pip install mkdocs mkdocs-macros-plugin mkdocs-exclude mike + + - name: Setup doc deploy + run: | + git config --global user.name "Knative Automation" + git config --global user.email automation@knative.team + + - name: Build docs + run: | + mike deploy dev --push diff --git a/hack/docker/Dockerfile b/hack/docker/Dockerfile new file mode 100644 index 000000000..9013b7252 --- /dev/null +++ b/hack/docker/Dockerfile @@ -0,0 +1,2 @@ +FROM squidfunk/mkdocs-material +RUN pip install --no-cache-dir mkdocs-macros-plugin mkdocs-exclude mike diff --git a/hack/docker/README.md b/hack/docker/README.md new file mode 100644 index 000000000..4c66948a0 --- /dev/null +++ b/hack/docker/README.md @@ -0,0 +1,19 @@ +# Development notes for working with mkdocs + +## Container + +Build the container image +```bash +./hack/docker/build.sh +``` + +Run the livereload site +```bash +./hack/docker/run.sh +``` + +Remove the container +```bash +./hack/docker/clean.sh +``` + diff --git a/hack/docker/build.sh b/hack/docker/build.sh new file mode 100755 index 000000000..f09241745 --- /dev/null +++ b/hack/docker/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +IMAGE=${1:-mkdocs} + +SCRIPT_DIR=$(cd $(dirname $0); pwd -P) +ROOT_DIR=$(cd "${SCRIPT_DIR}/.."; pwd -P) + +docker build -t ${IMAGE} ${SCRIPT_DIR} diff --git a/hack/docker/clean.sh b/hack/docker/clean.sh new file mode 100755 index 000000000..6113e4382 --- /dev/null +++ b/hack/docker/clean.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +NAME=${1:-mkdocs} + +echo "Cleaning up old container '${NAME}'..." +docker rm "${NAME}" --force 1> /dev/null 2> /dev/null + +echo "Finished clean up" diff --git a/hack/docker/mkdocs.sh b/hack/docker/mkdocs.sh new file mode 100755 index 000000000..eca654d35 --- /dev/null +++ b/hack/docker/mkdocs.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +PORT=${2:-8000} + +mkdocs serve --config-file "./mkdocs.yml" --livereload -a 0.0.0.0:${PORT} diff --git a/hack/docker/run.sh b/hack/docker/run.sh new file mode 100755 index 000000000..947fde23c --- /dev/null +++ b/hack/docker/run.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +NAME=${1:-mkdocs} +PORT=${2:-8000} +IMAGE=${3:-mkdocs} + +docker run --name "${NAME}" -d -p "${PORT}:${PORT}" -v "${PWD}:/site" mkdocs serve -f /site/mkdocs.yml --dirtyreload -a "0.0.0.0:${PORT}" +echo "Dev environment running with live reloading enabled. Open http://localhost:${PORT} to see the site" +echo "For live logs run:" +echo "docker logs -f ${NAME}"