1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-10-30 23:57:50 +02:00

Deploy mkdocs when merging to master

Only changes to master and PRs starts the travis job.
On PR Maven tests and mkdocs build for warnings and error check is done.
On change on master Maven is **not** run and the documentation is built
and deployed using a deploy key. The encrypted deploy key is not part of
this commit, it needs to be provided by an admin for this repository.
This commit is contained in:
Oliver Feldmann
2017-12-21 15:22:57 +01:00
committed by Marcus Holl
parent 99c5bacf00
commit 0a58ad6e1c
3 changed files with 30 additions and 1 deletions

View File

@@ -4,7 +4,21 @@ install:
- pip install --user mkdocs mkdocs-material
script:
- mvn test -B
- if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then cd documentation && mkdocs build --clean --verbose --strict && cd ..; fi;
- |
if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]
then
cd documentation && mkdocs build --clean --verbose --strict && cd ..
else
# Only in case we are in master branch of the leading SAP repo we would like to deploy,
# not from the forks.
if [[ "${TRAVIS_BRANCH}" == "master" && "${TRAVIS_REPO_SLUG}" == "SAP/jenkins-library" ]]
then
openssl aes-256-cbc -K $encrypted_12c8071d2874_key -iv $encrypted_12c8071d2874_iv -in cfg/id_rsa.enc -out cfg/id_rsa -d
./gh-pages-deploy.sh
else
echo "Publishing documentation skipped."
fi
fi
cache:
directories:
- $HOME/.m2

BIN
cfg/id_rsa.enc Normal file

Binary file not shown.

15
gh-pages-deploy.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
echo "Found change on master: Deployment of documentation"
PRIVATE_KEY="cfg/id_rsa"
chmod 600 "${PRIVATE_KEY}"
eval `ssh-agent -s`
ssh-add "${PRIVATE_KEY}"
git config user.name "Travis CI Publisher"
git remote add docu "git@github.com:$TRAVIS_REPO_SLUG.git";
git fetch docu gh-pages:gh-pages
echo "Pushing to gh-pages of repository $TRAVIS_REPO_SLUG"
cd $TRAVIS_BUILD_DIR/documentation
mkdocs gh-deploy -v --clean --remote-name docu