diff --git a/roles/webserver-content/org/nasqueron/docs.sls b/roles/webserver-content/org/nasqueron/docs.sls --- a/roles/webserver-content/org/nasqueron/docs.sls +++ b/roles/webserver-content/org/nasqueron/docs.sls @@ -7,7 +7,7 @@ {% if salt['node.has_web_content'](".org/nasqueron/docs") %} -{% from "map.jinja" import packages with context %} +{% from "map.jinja" import dirs, packages with context %} # ------------------------------------------------------------- # Base directory @@ -20,6 +20,20 @@ - dir_mode: 755 # ------------------------------------------------------------- +# Software to build the docs +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +sphinx: + pkg.installed: + - name: {{ packages.sphinx }} + +{{ dirs.bin }}/deploy-docker-registry-api-doc: + file.managed: + - source: salt://roles/webserver-content/org/nasqueron/files/build-docs-salt-wrapper.sh + - user: deploy + - mode: 755 + +# ------------------------------------------------------------- # Deploy a rSW docs dir HTML build to docs.n.o/salt-wrapper # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -58,11 +72,21 @@ - m_name: limiting-factor-doc # ------------------------------------------------------------- -# Software to build the docs +# Deploy a rAPIREG docs dir HTML build to docs.n.o/docker-registry-api +# +# Job: https://cd.nasqueron.org/job/docker-registry-api-doc/ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -sphinx: - pkg.installed: - - name: {{ packages.sphinx }} +/var/wwwroot/nasqueron.org/docs/docker-registry-api/rust: + file.directory: + - user: deploy + - group: web + - dir_mode: 755 + - makedirs: True + +docker_registry_api_doc_build: + module.run: + - name: jenkins.build_job + - m_name: docker-registry-api {% endif %} diff --git a/roles/webserver-content/org/nasqueron/files/deploy-docker-registry-api-doc.sh b/roles/webserver-content/org/nasqueron/files/deploy-docker-registry-api-doc.sh new file mode 100755 --- /dev/null +++ b/roles/webserver-content/org/nasqueron/files/deploy-docker-registry-api-doc.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# ------------------------------------------------------------- +# Nasqueron Docs +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Project: Nasqueron +# License: Trivial work, not eligible to copyright +# Source file: roles/webserver-content/org/nasqueron/files/build-docs-salt-wrapper.sh +# ------------------------------------------------------------- +# +# +# This file is managed by our rOPS SaltStack repository. +# +# Changes to this file may cause incorrect behavior +# and will be lost if the state is redeployed. +# + +PROJECT=docker-registry-api +JENKINS_JOB=$PROJECT-doc +SOURCE=https://cd.nasqueron.org/job/$JENKINS_JOB +TARBALL_PATH=~deploy/workspace +DOC_PATH=/var/wwwroot/nasqueron.org/docs/$PROJECT +EXIT_CODE=0 +DL=fetch +DL_ARGS="-o" + +if [ "$#" -eq 0 ]; then + echo "Usage: $0 " 1>&2; + exit 1 +fi +BUILD=$1 + +case $BUILD in + ''|*[!0-9]*) + echo "Build number argument must be an integer." + exit 1 + ;; + *) echo "Deploying documentation for build #$BUILD..." ;; +esac + +# Fetch files + +$DL $DL_ARGS $TARBALL_PATH/doc-$PROJECT-rust.tar.gz "$SOURCE/$BUILD/artifact/target/doc-rust.tar.gz" +$DL $DL_ARGS $TARBALL_PATH/doc-$PROJECT-openapi.tar.gz "$SOURCE/$BUILD/artifact/target/doc-openapi.tar.gz" +exit + +# Deploy + +if [ -f $TARBALL_PATH/doc-$PROJECT-rust.tar.gz ]; then + tar xzf $TARBALL_PATH/doc-$PROJECT-rust.tar.gz -C $DOC_PATH/rust/ + rm $TARBALL_PATH/doc-$PROJECT-rust.tar.gz +else + >&2 echo "Artifact not found: crate documentation archive (doc-$PROJECT-rust.tar.gz)" + EXIT_CODE=2 +fi + +if [ -f $TARBALL_PATH/doc-$PROJECT-openapi.tar.gz ]; then + tar xzf $TARBALL_PATH/doc-$PROJECT-openapi.tar.gz -C $DOC_PATH/ + rm $TARBALL_PATH/doc-$PROJECT-openapi.tar.gz +else + >&2 echo "Artifact not found: OpenAPI Spectacle documentation archive (doc-$PROJECT-openapi.tar.gz)" + EXIT_CODE=$((EXIT_CODE+4)) +fi + +exit $EXIT_CODE