xref: /OpenGrok/dev/javadoc.sh (revision 45e0b9056f098a348e99521f314569235b4d52fa)
1#!/bin/bash
2
3set -e
4set -x
5
6if [[ -z "$OPENGROK_BUILD_DIR" ]]; then
7	echo -e "empty OPENGROK_BUILD_DIR"
8	exit 1
9fi
10
11if [[ -n $OPENGROK_REF && $OPENGROK_REF == refs/heads/* ]]; then
12	OPENGROK_BRANCH=${OPENGROK_REF#"refs/heads/"}
13fi
14
15if [[ "${OPENGROK_REPO_SLUG}" != "oracle/opengrok" ||
16    -n "${OPENGROK_PULL_REQUEST}" ||
17    "${OPENGROK_BRANCH}" != "master" ]]; then
18	echo "Skipping Javadoc refresh"
19	exit 0
20fi
21
22BRANCH="gh-pages"
23
24echo -e "Building Javadoc...\n"
25./mvnw -DskipTests=true site
26
27echo -e "Publishing javadoc to $BRANCH...\n"
28git config --global user.name "github-actions[bot]"
29git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
30
31cd "$BRANCH"
32if [[ -d ./javadoc ]]; then
33	git rm -rf ./javadoc
34fi
35cp -Rf "$OPENGROK_BUILD_DIR/target/site/apidocs" ./javadoc
36git add -f ./javadoc
37git commit -m "Lastest javadoc auto-pushed to branch $BRANCH"
38git push -fq origin "$BRANCH"
39
40echo -e "Published Javadoc to branch $BRANCH.\n"
41