From 58d81600a2bc4081c5955f93740246490ad5af90 Mon Sep 17 00:00:00 2001 From: Danil Grigorev Date: Tue, 21 Nov 2023 11:53:40 +0100 Subject: [PATCH] Add workflow for a book publishing job --- .github/workflows/documentation.yaml | 36 ++++++++++++++++++++++++++++ docs/book/Makefile | 34 ++++++++++++++++++++++++++ docs/book/book.toml | 26 ++++++++++++++++++++ docs/book/src/01_intro.md | 8 +++++++ docs/book/src/SUMMARY.md | 0 scripts/ci-install-mdbook.sh | 34 ++++++++++++++++++++++++++ 6 files changed, 138 insertions(+) create mode 100644 .github/workflows/documentation.yaml create mode 100644 docs/book/Makefile create mode 100644 docs/book/book.toml create mode 100644 docs/book/src/01_intro.md create mode 100644 docs/book/src/SUMMARY.md create mode 100755 scripts/ci-install-mdbook.sh diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 000000000..527e86c87 --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,36 @@ +name: Documentation + +on: + workflow_dispatch: + push: + branches: + - main + +permissions: + contents: read + pages: write + id-token: write + +jobs: + gh-pages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: make -C docs/book build + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: ./docs/book/book + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: gh-pages + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 + diff --git a/docs/book/Makefile b/docs/book/Makefile new file mode 100644 index 000000000..45b625e35 --- /dev/null +++ b/docs/book/Makefile @@ -0,0 +1,34 @@ +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Directories. +TOOLS_DIR := $(realpath ../../hack/tools) +TOOLS_BIN_DIR := $(TOOLS_DIR)/bin +BIN_DIR := bin +MDBOOK_INSTALL := $(realpath ../../scripts/ci-install-mdbook.sh) + +export PATH := $(abspath $(TOOLS_BIN_DIR)/bin):$(PATH) + +# Only set MDBOOK if it's not set as an environment variable +MDBOOK ?= $(TOOLS_BIN_DIR)/bin/mdbook +$(MDBOOK): + $(MDBOOK_INSTALL) 0.4.35 $(TOOLS_BIN_DIR) + +.PHONY: serve +serve: $(MDBOOK) + $(MDBOOK) serve + +.PHONY: build +build: $(MDBOOK) + $(MDBOOK) build \ No newline at end of file diff --git a/docs/book/book.toml b/docs/book/book.toml new file mode 100644 index 000000000..1fdcf2fa9 --- /dev/null +++ b/docs/book/book.toml @@ -0,0 +1,26 @@ +[book] +language = "en" +multilingual = false +src = "src" +title = "Cluster API Operator" +description = "Cluster API Operator" + +[preprocessor.toc] +command = "mdbook-toc" +marker = "[[_TOC_]]" + +[preprocessor.fs-summary] +# (default: true) +clean-paths = false + +# other preprocessors will naturally need to +# run after the summary has been generated +[preprocessor.links] +after = ["fs-summary"] + +[output.html] +mathjax-support = true +git-repository-url = "https://github.com/kubernetes-sigs/cluster-api-operator" +git-repository-icon = "fa-github" +site-url = "/cluster-api-operator/" + diff --git a/docs/book/src/01_intro.md b/docs/book/src/01_intro.md new file mode 100644 index 000000000..fb538f579 --- /dev/null +++ b/docs/book/src/01_intro.md @@ -0,0 +1,8 @@ +# Cluster API Operator + +## ✨ What is Cluster API Operator? + +The **Cluster API Operator** is a Kubernetes Operator designed to empower cluster administrators to handle the lifecycle of Cluster API providers within a management cluster using a declarative approach. It aims to improve user experience in deploying and managing Cluster API, making it easier to handle day-to-day tasks and automate workflows with GitOps. + +This operator leverages a declarative API and extends the capabilities of the `clusterctl` CLI, allowing greater flexibility and configuration options for cluster administrators. + diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/ci-install-mdbook.sh b/scripts/ci-install-mdbook.sh new file mode 100755 index 000000000..eccecb7c0 --- /dev/null +++ b/scripts/ci-install-mdbook.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +VERSION=${1} +OUTPUT_PATH=${2} + +# Ensure the output folder exists +mkdir -p "${OUTPUT_PATH}" + +# Install cargo +curl https://sh.rustup.rs -sSf | sh -s -- -y +. "$HOME/.cargo/env" + +# Install mdbook and dependencies +cargo install mdbook --version "$VERSION" --root "$OUTPUT_PATH" +cargo install mdbook-fs-summary --root "$OUTPUT_PATH" +cargo install mdbook-toc --root "$OUTPUT_PATH"