Merge pull request 'Conditionally deploy based on the current branch' (#2) from clement.freville2/codefirst-docdeployer:feature/conditional-deploy into master

Reviewed-on: maxime.batista/codefirst-docdeployer#2
test-script
Maxime BATISTA 2 years ago
commit 65ff547bc6

@ -15,6 +15,7 @@ This command generates the documentation and deploys it on your CodeDoc space
### Arguments
- `-b --branch [branch]` pattern of branch names to deploy
- `-l --loc [dir]` location of the documentation sources root - **required**
- `-t --type [docusaurus|doxygen|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>**
@ -27,7 +28,7 @@ Usage examples :
```
/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 ./src/Doxyfile -t doxygen -d sourcecode_documentation
/entrypoint.sh -b main -l ./src/Doxyfile -t doxygen -d sourcecode_documentation
```
### How to add a custom documentation generator ?

@ -10,14 +10,20 @@ help() {
usage: $0
-l --loc [dir] location of the documentation sources root - required
-t --type [docusaurus|doxygen|swagger] type of documentation generator to use. - required
-b --branch [branch] pattern of branch names to deploy - optional
-d --dest [dir] path to where to put the documentation outputs in your repository's CodeDoc space - optional !! cannot be absolute !!
EOF
exit 1
}
BRANCH=""
DEST=""
while [ "$1" ]; do
case "$1" in
"-b" | "--branch")
BRANCH="$2"
shift 1
;;
"-d" | "--dest")
DEST="$2"
shift 1
@ -53,6 +59,11 @@ 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
echo "ignoring deploy step since current branch doesn't match $BRANCH"
exit
fi
SERVER_TARGET="/usr/share/nginx/html/$RELATIVE_PATH"
# launches rsync in archive, verbose and compression mode

Loading…
Cancel
Save