From cc7aa8a415f9a86683af4a97c720c104284ff465 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Thu, 2 Mar 2023 10:01:30 -0500 Subject: [PATCH 1/2] docs: test builds without deploying for PRs Signed-off-by: Andy Goldstein --- .github/workflows/docs-gen-and-push.yaml | 4 +++ hack/deploy-docs.sh | 31 +++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docs-gen-and-push.yaml b/.github/workflows/docs-gen-and-push.yaml index 4574a5a37d7..3bd9d5c43c5 100644 --- a/.github/workflows/docs-gen-and-push.yaml +++ b/.github/workflows/docs-gen-and-push.yaml @@ -1,7 +1,11 @@ name: Generate and push docs on: + # So we can trigger manually if needed workflow_dispatch: + # To confirm any changes to docs build successfully, without deploying them + pull_request: + # Pushes to branches do the full build + deployment push: branches: - main diff --git a/hack/deploy-docs.sh b/hack/deploy-docs.sh index d59b7e4bd51..74e3195d827 100755 --- a/hack/deploy-docs.sh +++ b/hack/deploy-docs.sh @@ -22,17 +22,24 @@ set -o xtrace REPO_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) cd "$REPO_ROOT/docs" -if [[ -n "${GITHUB_REF_NAME:-}" ]]; then - VERSION="${VERSION:-$GITHUB_REF_NAME}" +if [[ "${GITHUB_EVENT_NAME:-}" == "pull_request" ]]; then + # For PRs, we don't want to use GITHUB_REF_NAME, which will be something like merge/1234; instead, we want to use + # the branch the PR is targeting, such as main or release-0.11 + VERSION=$GITHUB_BASE_REF else - VERSION=${VERSION:-$(git rev-parse --abbrev-ref HEAD)} + if [[ -n "${GITHUB_REF_NAME:-}" ]]; then + VERSION="${VERSION:-$GITHUB_REF_NAME}" + else + VERSION=${VERSION:-$(git rev-parse --abbrev-ref HEAD)} + fi + + if echo "$VERSION" | grep '^release-[0-9]'; then + VERSION=v$(echo "$VERSION" | cut -d - -f 2) + elif echo "$VERSION" | grep '^v[0-9]\+\.[0-9]\+'; then + VERSION=$(echo "$VERSION" | grep -o '^v[0-9]\+\.[0-9]\+') + fi fi -if echo "$VERSION" | grep '^release-[0-9]'; then - VERSION=v$(echo "$VERSION" | cut -d - -f 2) -elif echo "$VERSION" | grep '^v[0-9]\+\.[0-9]\+'; then - VERSION=$(echo "$VERSION" | grep -o '^v[0-9]\+\.[0-9]\+') -fi MIKE_OPTIONS=() @@ -44,11 +51,13 @@ if [[ -n "${BRANCH:-}" ]]; then MIKE_OPTIONS+=(--branch "$BRANCH") fi +git config user.name kcp-docs-bot +git config user.email no-reply@kcp.io -if [[ -n "${CI:-}" ]]; then +# Only push to gh-pages if we're in GitHub Actions (CI is set) and we have a non-PR event. +if [[ -n "${CI:-}" && "${GITHUB_EVENT_NAME:-}" == "push" ]]; then MIKE_OPTIONS+=(--push) - git config user.name kcp-docs-bot - git config user.email no-reply@kcp.io + fi mike deploy "${MIKE_OPTIONS[@]}" "$VERSION" From 8bdd88a6eebed0e62847a66bc97171276429ecd6 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Thu, 2 Mar 2023 10:04:44 -0500 Subject: [PATCH 2/2] docs: update material to 9.1.0 Signed-off-by: Andy Goldstein --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index cdada816b59..406642773fd 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,7 +5,7 @@ mike==1.1.2 mkdocs==1.4.2 mkdocs-awesome-pages-plugin==2.8.0 mkdocs-macros-plugin==0.7.0 -mkdocs-material==9.0.11 +mkdocs-material==9.1.0 mkdocs-material-extensions==1.1.1 mkdocs-static-i18n==0.53 Pygments==2.14.0