From 2fa02bc1c0ea46c022e74a55f28033ee81cdc2d7 Mon Sep 17 00:00:00 2001 From: yangsoon Date: Mon, 17 May 2021 19:09:37 +0800 Subject: [PATCH] Preview and Build website in docker container (#1668) * start/build docs in docker * restore old fashion * fix release ci --- .github/workflows/release.yml | 9 +++++++-- Makefile | 19 +++++++----------- docs/README.md | 18 +++++++++++++---- docs/en/cli/vela_system_cue-packages.md | 2 +- docs/en/cli/vela_system_live-diff.md | 2 +- hack/website/docs-start.sh | 26 +++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 hack/website/docs-start.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c102a2476..bbdaeb4cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -127,7 +127,12 @@ jobs: asset_content_type: text/plain - uses: actions/setup-node@v1 with: - node-version: '12.x' + node-version: "12.x" + - uses: actions/setup-python@v2 + with: + python-version: "3.7" + - name: Clean md files + run: python ./hack/website/clean-md.py ./docs/en - name: Sync release to kubevela.io Repo env: SSH_DEPLOY_KEY: ${{ secrets.GH_PAGES_DEPLOY }} @@ -136,4 +141,4 @@ jobs: run: | bash ./hack/website/release.sh - name: Update kubectl plugin version in krew-index - uses: rajatjindal/krew-release-bot@v0.0.38 \ No newline at end of file + uses: rajatjindal/krew-release-bot@v0.0.38 diff --git a/Makefile b/Makefile index 26192d98d..3e53eaf5d 100644 --- a/Makefile +++ b/Makefile @@ -66,21 +66,16 @@ doc-gen: rm -r docs/en/cli/* go run hack/docgen/gen.go +PWD := $(shell pwd) docs-build: -ifneq ($(wildcard git-page),) - rm -rf git-page -endif - sh ./hack/website/test-build.sh + docker run -it -v $(PWD)/docs/sidebars.js:/workspace/kubevela.io/sidebars.js \ + -v $(PWD)/docs/en:/workspace/kubevela.io/docs \ + yangsoon/kubevela.io:v1 -t build docs-start: -ifeq ($(wildcard git-page),) - git clone --single-branch --depth 1 https://github.com/oam-dev/kubevela.io.git git-page -endif - rm -r git-page/docs - rm git-page/sidebars.js - cat docs/sidebars.js > git-page/sidebars.js - cp -R docs/en git-page/docs - cd git-page && yarn install && yarn start + docker run -it -p 3000:3000 -v $(PWD)/docs/sidebars.js:/workspace/kubevela.io/sidebars.js \ + -v $(PWD)/docs/en:/workspace/kubevela.io/docs \ + yangsoon/kubevela.io:v1 -t start api-gen: swag init -g references/apiserver/route.go --output references/apiserver/docs diff --git a/docs/README.md b/docs/README.md index e92479abf..2e57f62e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,19 +54,29 @@ When you add or modify the docs, these three files(`docs/en/`, `docs/en/resource [comment]: <> (TODO: ADD how to translate into Chinese or other language here.) -## Local Development +## Preview Website -You can preview the website locally with the `node` and `yarn` installed. -Every time you modify the files under the docs, you need to re-run the following command, it will not sync automatically: +You can preview the website locally with docker container. Every time you modify the files under the docs or sidebars.js, +it will sync automatically: ```shell make docs-start ``` -## Build in Local +## Build Website You can build Kubevela website in local to test the correctness of docs, only run the following cmd: ```shell make docs-build +``` + +If you don't want to use docker to preview and build the website, we provide simple scripts in the `hack/website` to help you develop and debug locally. + +``` +# preview the website +sh hack/website/docs-start.sh + +# build the website +sh hack/website/test-build.sh ``` \ No newline at end of file diff --git a/docs/en/cli/vela_system_cue-packages.md b/docs/en/cli/vela_system_cue-packages.md index 966e7619a..da92e69d8 100644 --- a/docs/en/cli/vela_system_cue-packages.md +++ b/docs/en/cli/vela_system_cue-packages.md @@ -30,6 +30,6 @@ vela system cue-packages ### SEE ALSO -* [vela system](vela_system.md) - System management utilities +* [vela system](vela_system) - System management utilities ###### Auto generated by spf13/cobra on 2-May-2021 diff --git a/docs/en/cli/vela_system_live-diff.md b/docs/en/cli/vela_system_live-diff.md index 498d1bdd5..a86061fb3 100644 --- a/docs/en/cli/vela_system_live-diff.md +++ b/docs/en/cli/vela_system_live-diff.md @@ -34,6 +34,6 @@ vela live-diff -f app-v2.yaml -r app-v1 --context 10 ### SEE ALSO -* [vela system](vela_system.md) - System management utilities +* [vela system](vela_system) - System management utilities ###### Auto generated by spf13/cobra on 2-May-2021 diff --git a/hack/website/docs-start.sh b/hack/website/docs-start.sh new file mode 100644 index 000000000..6c5e0ab68 --- /dev/null +++ b/hack/website/docs-start.sh @@ -0,0 +1,26 @@ +#!/bin/bash -l +# +# Copyright 2021. The KubeVela 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. +# + +if [ ! -d "./git-page" ]; then + git clone --single-branch --depth 1 https://github.com/oam-dev/kubevela.io.git git-page +fi + +rm -r git-page/docs +rm git-page/sidebars.js +cat docs/sidebars.js > git-page/sidebars.js +cp -R docs/en git-page/docs +cd git-page && yarn install && yarn start \ No newline at end of file