Compare commits

..

No commits in common. 'master' and 'test-script' have entirely different histories.

@ -3,8 +3,6 @@ type: docker
name: build name: build
trigger: trigger:
branch:
- build
event: event:
- push - push
@ -19,11 +17,13 @@ steps:
- name: docker-build - name: docker-build
image: plugins/docker image: plugins/docker
depends_on:
- key-setup
settings: settings:
dockerfile: Dockerfile dockerfile: Dockerfile
context: . context: .
registry: hub.codefirst.iut.uca.fr registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/alexandre.agostinho/codefirst-docdeployer repo: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer
username: username:
from_secret: SECRET_REGISTRY_USERNAME from_secret: SECRET_REGISTRY_USERNAME
password: password:

@ -1,26 +1,16 @@
# Docdeployer # Docdeployer
A Drone CI tool to easily deploy documentation on CodeDoc Usage:
## Note
This repo is forked from <https://codefirst.iut.uca.fr/git/maxime.batista/codefirst-docdeployer>.
I only made a few small changes to this repository to adapt it to my way of working.
## Usage:
```yml ```yml
steps: steps:
- name: generate-and-deploy-docs - name: swagger-doc
image: hub.codefirst.iut.uca.fr/alexandre.agostinho/codefirst-docdeployer:latest image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer
failure: ignore
volumes:
- name: docs
path: /docs
commands: commands:
- /entrypoint.sh <arguments> - /entrypoint.sh <arguments>
``` ```
`entrypoint.sh` ## `entrypoint.sh`
This command generates the documentation and deploys it on your CodeDoc space This command generates the documentation and deploys it on your CodeDoc space
### Arguments ### Arguments
@ -30,15 +20,25 @@ This command generates the documentation and deploys it on your CodeDoc space
- `-t --type [docusaurus|doxygen|mdbook|swagger]` type of documentation generator to use. - **required** - `-t --type [docusaurus|doxygen|mdbook|swagger]` type of documentation generator to use. - **required**
- `-d --dest [dir]` path to where to put the documentation outputs in your repository's CodeDoc space - **optional <u>!! cannot be absolute !!</u>** - `-d --dest [dir]` path to where to put the documentation outputs in your repository's CodeDoc space - **optional <u>!! cannot be absolute !!</u>**
### Examples : Note !
For swagger and doxygen, you have to pass the configuration file instead of a directory
Usage examples :
``` ```
/entrypoint.sh -l ./documentation/api/api-swagger.yml -t swagger -d api_documentation /entrypoint.sh -l ./documentation/api/api-swagger.yml -t swagger -d api_documentation
/entrypoint.sh -l ./documentation/app -t docusaurus -d application_documentation /entrypoint.sh -l ./documentation/app -t docusaurus -d application_documentation
/entrypoint.sh -b main -l ./documentation/doxygen/ -t doxygen -d sourcecode_documentation /entrypoint.sh -b main -l ./src/Doxyfile -t doxygen -d sourcecode_documentation
/entrypoint.sh -l ./doc -t mdbook -d book /entrypoint.sh -l ./doc -t mdbook -d book
``` ```
--- ### How to add a custom documentation generator ?
The `-t <g>` (`--type <g>`) option lookups for a generator script `<g>`.sh to be present in the `/generators`
(ex: `--type doxygen` searchs for a `/generators/doxygen.sh` file script).
You can add your own generator by simply moving your script into the `/generators` folder
For more informations, check the [original repository](https://codefirst.iut.uca.fr/git/maxime.batista/codefirst-docdeployer). Furthermore, your generator MUST follow below specifications :
* Define a `generate()` function that will be called, assuming that `$1` equals to the value passed after `-l` (`--loc`) which is the documentation sources location
* Define a `GEN_PATH` variable which is the path of generated outputs
* Place generated outputs in the `GEN_PATH` folder, the caller will then upload generated sources onto the user's CodeDoc space

@ -56,14 +56,14 @@ fi
RELATIVE_PATH=$(echo "$DRONE_REPO_OWNER/$DRONE_REPO_NAME/$DEST/" | tr -s "/") RELATIVE_PATH=$(echo "$DRONE_REPO_OWNER/$DRONE_REPO_NAME/$DEST/" | tr -s "/")
. "$GENERATOR_SCRIPT"
generate "$DOC_DIR" # generates doc using the wanted generator
if [[ -n $BRANCH && ! $DRONE_BRANCH =~ $BRANCH ]]; then if [[ -n $BRANCH && ! $DRONE_BRANCH =~ $BRANCH ]]; then
echo "ignoring deploy step since current branch doesn't match $BRANCH" echo "ignoring deploy step since current branch doesn't match $BRANCH"
exit exit
fi fi
. "$GENERATOR_SCRIPT"
generate "$DOC_DIR" # generates doc using the wanted generator
SERVER_TARGET="/usr/share/nginx/html/$RELATIVE_PATH" SERVER_TARGET="/usr/share/nginx/html/$RELATIVE_PATH"
# launches rsync in archive, verbose and compression mode # launches rsync in archive, verbose and compression mode

@ -7,7 +7,9 @@ generate() {
exit 1 exit 1
fi fi
doxygen -u
doxygen "$1"
mkdir -p $GEN_PATH mkdir -p $GEN_PATH
cd "$1" mv html/* $GEN_PATH
(cat Doxyfile; echo -e "\nOUTPUT_DIRECTORY = \nHTML_OUTPUT = $GEN_PATH") | doxygen -
} }

@ -2,7 +2,7 @@
set -eu set -eu
declare -g EXPECTED_DOC_BASE_PATH='/usr/share/nginx/html/octocat/hello-world' declare -g EXCEPTED_DOC_BASE_PATH='/usr/share/nginx/html/octocat/hello-world'
declare -g VERBOSE='false' declare -g VERBOSE='false'
root_dir=$(readlink -f $(dirname $(realpath "$0"))/..) root_dir=$(readlink -f $(dirname $(realpath "$0"))/..)
@ -33,7 +33,6 @@ run_image() {
-e DRONE_BRANCH=$branch \ -e DRONE_BRANCH=$branch \
-e DRONE_COMMIT=7fd1a60b01f91b314f59955a4e4d4e80d8edf11d \ -e DRONE_COMMIT=7fd1a60b01f91b314f59955a4e4d4e80d8edf11d \
--entrypoint '/bin/bash' \ --entrypoint '/bin/bash' \
--workdir /drone/src \
--rm codefirst-docdeployer \ --rm codefirst-docdeployer \
-c "sed -i 's/ssh/ssh -p 2222/g' /entrypoint.sh && sed -i 's/root@nginx/codefirst@nginx/g' /entrypoint.sh && $*" -c "sed -i 's/ssh/ssh -p 2222/g' /entrypoint.sh && sed -i 's/root@nginx/codefirst@nginx/g' /entrypoint.sh && $*"
docker stop "$nginx_id" docker stop "$nginx_id"
@ -52,7 +51,7 @@ cleanup() {
assert_file_exists() { assert_file_exists() {
# Assert that the given file exists in the codefirst-nginx volume. # Assert that the given file exists in the codefirst-nginx volume.
if check_on_deployed test -f "$EXPECTED_DOC_BASE_PATH/$1"; then if check_on_deployed test -f "$EXCEPTED_DOC_BASE_PATH/$1"; then
echo -e "$1 exists: \e[32mOK\e[0m" echo -e "$1 exists: \e[32mOK\e[0m"
else else
echo -e "$1 does not exist: \e[31mFAILED\e[0m" echo -e "$1 does not exist: \e[31mFAILED\e[0m"
@ -64,12 +63,12 @@ assert_file_exists() {
assert_file_contains() { assert_file_contains() {
# Assert that the given file contains the given string. # Assert that the given file contains the given string.
if check_on_deployed grep -q $2 "$EXPECTED_DOC_BASE_PATH/$1"; then if check_on_deployed grep -q $2 "$EXCEPTED_DOC_BASE_PATH/$1"; then
echo -e "$1 exists and matches content: \e[32mOK\e[0m" echo -e "$1 exists and matches content: \e[32mOK\e[0m"
elif check_on_deployed test -f "$EXPECTED_DOC_BASE_PATH/$1"; then elif check_on_deployed test -f "$EXCEPTED_DOC_BASE_PATH/$1"; then
echo -e "$1 exists but does not match content: \e[31mFAILED\e[0m" echo -e "$1 exists but does not match content: \e[31mFAILED\e[0m"
if [[ "$VERBOSE" == 'true' ]]; then if [[ "$VERBOSE" == 'true' ]]; then
check_on_deployed cat "$EXPECTED_DOC_BASE_PATH/$1" check_on_deployed cat "$EXCEPTED_DOC_BASE_PATH/$1"
fi fi
else else
echo -e "$1 does not exist: \e[31mFAILED\e[0m" echo -e "$1 does not exist: \e[31mFAILED\e[0m"
@ -95,16 +94,5 @@ test_swagger() {
cleanup cleanup
} }
test_mdbook() {
run_image master 'mkdir -p doc/src \
&& touch doc/book.toml \
&& touch doc/src/index.md \
&& echo "[Introduction](index.md)" > doc/src/SUMMARY.md \
&& /entrypoint.sh -l doc -t mdbook'
assert_file_exists book/index.html
cleanup
}
test_doxygen test_doxygen
test_swagger test_swagger
test_mdbook

Loading…
Cancel
Save