Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make targets and github workflow for publishing docs #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Docs
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- .github/workflows/docs*
- docs/**
- Gemfile
jobs:
deploy:
if: github.repository == 'openstack-k8s-operators/watcher-operator'
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
- uses: actions/checkout@v4
with:
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
fetch-depth: 0
- uses: ruby/[email protected]
with:
ruby-version: '3.2'

- name: Build docs
run: |
make docs
cp docs_build/watcher-operator/index.html index.html
- name: Prepare gh-pages branch
run: |
git config user.name github-actions
git config user.email [email protected]
git branch -D gh-pages &>/dev/null || true
git checkout --orphan gh-pages
git reset
- name: Commit asciidoc docs
run: |
git add index.html
git commit -m "Rendered docs"
- name: Push rendered docs to gh-pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git push --force origin gh-pages
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
bin/*
Dockerfile.cross

# Ruby bundle related files
/.bundle
/Gemfile.lock
/local
docs/main.adoc
/docs_build

# Test binary, built with `go test -c`
*.test

Expand Down
11 changes: 11 additions & 0 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
github-check:
jobs:
- noop
- watcher-operator-doc-preview
- openstack-meta-content-provider:
vars:
cifmw_operator_build_meta_build: false
Expand Down Expand Up @@ -60,3 +61,13 @@
source: "{{ watcher_hook }}"
extra_vars:
watcher_catalog_image: "{{ content_provider_registry_ip }}:5001/openstack-k8s-operators/watcher-operator-index:{{ zuul.patchset }}"

- job:
name: watcher-operator-doc-preview
parent: cifmw-doc
files:
- docs
- Gemfile
vars:
asciidoc_available: true
doc_available: false
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source 'https://rubygems.org'

gem 'asciidoctor', '~> 2.0', '>= 2.0.20'

# Uncomment for ability to convert Markdown to AsciiDoc
gem 'kramdown-asciidoc'

# Needed for https://github.com/ruby/rexml/issues/131#issuecomment-2116267578
gem 'rexml', '= 3.2.6'
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,34 @@ run-with-webhook: export HEALTH_PORT?=33081
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
/bin/bash hack/clean_local_webhook.sh
/bin/bash hack/run_with_local_webhook.sh

##@ Docs

.PHONY: docs-dependencies
docs-dependencies: .bundle ## Convert markdown docs to ascii docs
bundle exec kramdoc README.md -o docs/main.adoc

.PHONY: .bundle
.bundle:
if ! type bundle; then \
echo "Bundler not found. On Linux run 'sudo dnf install /usr/bin/bundle' to install it."; \
exit 1; \
fi

bundle config set --local path 'local/bundle'; bundle install

.PHONY: docs
docs: docs-dependencies ## Build docs
cd docs; $(MAKE) html

.PHONY: docs-preview
docs-preview: docs
cd docs; $(MAKE) open-html

.PHONY: docs-watch
docs-watch: docs-preview
cd docs; $(MAKE) watch-html

.PHONY: docs-clean
docs-clean:
rm -r docs_build
51 changes: 51 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
BUILD_DIR = ../docs_build
ROOTDIR = $(realpath .)
NAME = watcher-operator
DEST_DIR = $(BUILD_DIR)/$(NAME)
DEST_HTML = $(DEST_DIR)/index.html
IMAGES_DIR = $(DEST_DIR)/images
IMAGES_TS = $(DEST_DIR)/.timestamp-images
MAIN_SOURCE = main.adoc
OTHER_SOURCES = $(shell find ./assemblies -type f)
IMAGES = $(shell find ./images -type f)
ALL_SOURCES = $(MAIN_SOURCE) $(OTHER_SOURCES) $(IMAGES)
UNAME = $(shell uname)
BUNDLE_EXEC ?= bundle exec

ifeq ($(UNAME), Linux)
BROWSER_OPEN = xdg-open
endif
ifeq ($(UNAME), Darwin)
BROWSER_OPEN = open
endif

all: html

html: html-latest

html-latest: prepare $(IMAGES_TS) $(DEST_HTML)

prepare:
@mkdir -p $(BUILD_DIR)
@mkdir -p $(DEST_DIR) $(IMAGES_DIR)

clean:
@rm -rf "$(DEST_DIR)"

watch-html:
@which inotifywait > /dev/null || ( echo "ERROR: inotifywait not found, install inotify-tools" && exit 1 )
while true; do \
inotifywait -r -e modify -e create -e delete .; \
sleep 0.5; \
$(MAKE) html; \
done

open-html: html
${BROWSER_OPEN} "file://$(realpath $(ROOTDIR)/$(DEST_HTML))"

$(IMAGES_TS): $(IMAGES)
cp $? $(IMAGES_DIR)
touch $(IMAGES_TS)

$(DEST_HTML): $(ALL_SOURCES)
$(BUNDLE_EXEC) asciidoctor -a source-highlighter=highlightjs -a highlightjs-languages="yaml,bash" -a highlightjs-theme="monokai" --failure-level WARN -a build=$(BUILD) -b xhtml5 -d book -o $@ $(MAIN_SOURCE)
Empty file added docs/assemblies/.gitkeep
Empty file.
Empty file added docs/images/.gitkeep
Empty file.
Loading