diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e32f695 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,51 @@ +variables: + DEPLOY_USER: deploy + DEPLOY_HOST: acs-os-fein-website + DEPLOY_PATH: /var/www/villas/api/web/ + +stages: + - prepare + - doc + - deploy + +# Stage: prepare +############################################################################## + +# Build docker image which is used to build & test VILLASnode +prepare:redoc: + stage: prepare + script: + - docker build -f doc/api/Dockerfile -t redoc . + tags: + - shell + - linux + +# Stage: doc +############################################################################## + +doc:api: + stage: doc + tags: + - docker + image: redoc + script: + - cd doc/api + - redoc-cli bundle --cdn --title "VILLASweb Backend API Documentation" --output index.html api.yaml + artifacts: + paths: + - doc/api/index.html + +# Stage: deploy +############################################################################## + +deploy:upload: + stage: deploy + script: + - cd doc/api + - rsync --copy-links --chown ${DEPLOY_USER}:${DEPLOY_USER} index.html api.yaml ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH} + dependencies: + - doc:api +# only: +# - master + tags: + - shell diff --git a/doc/api/Dockerfile b/doc/api/Dockerfile new file mode 100644 index 0000000..88bfab8 --- /dev/null +++ b/doc/api/Dockerfile @@ -0,0 +1,3 @@ +FROM node:8 + +RUN npm -g install redoc-cli diff --git a/doc/api/Makefile b/doc/api/Makefile index 5fffd40..97118b8 100644 --- a/doc/api/Makefile +++ b/doc/api/Makefile @@ -1,14 +1,20 @@ -REDOC := $(shell command -v redoc-cli 2> /dev/null) +TITLE := "VILLASweb Backend API Documentation" + +DEPLOY_USER ?= deploy +DEPLOY_HOST ?= acs-os-fein-website +DEPLOY_PATH ?= /var/www/villas/api/web/ + +RSYNC_OPTS ?= --recursive --ignore-missing-args --copy-links --chown $(DEPLOY_USER):$(DEPLOY_USER) all: index.html index.html: api.yaml -ifndef REDOC - $(error "redoc-cli is not available, please install via npm install -g redoc-cli (run as root)") -endif - redoc-cli bundle -o villaswebapi.html api.yaml + redoc-cli bundle --cdn --title "$(TITLE)" --output $@ api.yaml + +deploy: index.html + rsync $(RSYNC_OPTS) index.html api.yaml $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH) clean: rm -rf index.html -.PHONY: docs index.html clean +.PHONY: docs clean deploy