xref: /OpenGrok/dev/javadoc.sh (revision 45e0b9056f098a348e99521f314569235b4d52fa)
117ce305cSVladimir Kotal#!/bin/bash
217ce305cSVladimir Kotal
317ce305cSVladimir Kotalset -e
4d57bcbe0SVladimir Kotalset -x
517ce305cSVladimir Kotal
6*45e0b905SVladimir Kotalif [[ -z "$OPENGROK_BUILD_DIR" ]]; then
7*45e0b905SVladimir Kotal	echo -e "empty OPENGROK_BUILD_DIR"
8*45e0b905SVladimir Kotal	exit 1
9*45e0b905SVladimir Kotalfi
10*45e0b905SVladimir Kotal
1180a86e86SVladimir Kotalif [[ -n $OPENGROK_REF && $OPENGROK_REF == refs/heads/* ]]; then
1280a86e86SVladimir Kotal	OPENGROK_BRANCH=${OPENGROK_REF#"refs/heads/"}
1380a86e86SVladimir Kotalfi
1480a86e86SVladimir Kotal
1580a86e86SVladimir Kotalif [[ "${OPENGROK_REPO_SLUG}" != "oracle/opengrok" ||
1680a86e86SVladimir Kotal    -n "${OPENGROK_PULL_REQUEST}" ||
1780a86e86SVladimir Kotal    "${OPENGROK_BRANCH}" != "master" ]]; then
18efc06f38SVladimir Kotal	echo "Skipping Javadoc refresh"
19c34749e2SVladimir Kotal	exit 0
20c34749e2SVladimir Kotalfi
21c34749e2SVladimir Kotal
22b59b9fafSVladimir KotalBRANCH="gh-pages"
23c34749e2SVladimir Kotal
24538a5d11SVladimir Kotalecho -e "Building Javadoc...\n"
2586b0ab6bSAdam Hornacek./mvnw -DskipTests=true site
2617ce305cSVladimir Kotal
27538a5d11SVladimir Kotalecho -e "Publishing javadoc to $BRANCH...\n"
2816762577SVladimir Kotalgit config --global user.name "github-actions[bot]"
2916762577SVladimir Kotalgit config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
3017ce305cSVladimir Kotal
31b59b9fafSVladimir Kotalcd "$BRANCH"
3217ce305cSVladimir Kotalif [[ -d ./javadoc ]]; then
3317ce305cSVladimir Kotal	git rm -rf ./javadoc
3417ce305cSVladimir Kotalfi
35*45e0b905SVladimir Kotalcp -Rf "$OPENGROK_BUILD_DIR/target/site/apidocs" ./javadoc
3617ce305cSVladimir Kotalgit add -f ./javadoc
37b59b9fafSVladimir Kotalgit commit -m "Lastest javadoc auto-pushed to branch $BRANCH"
38b59b9fafSVladimir Kotalgit push -fq origin "$BRANCH"
39c34749e2SVladimir Kotal
40b59b9fafSVladimir Kotalecho -e "Published Javadoc to branch $BRANCH.\n"
41