This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish documentation | |
run-name: Build | |
on: | |
push: | |
branches: | |
- gh-pages | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: build and copy javadoc | |
run: | | |
mvn clean package -DskipTest | |
project_version=$(ls -d target/reports/*/ | head -n 1 | xargs basename) | |
if [ -z "$project_version" ]; then | |
echo "Error: \$project_version is not defined. Check build process and project version." >&2 | |
exit 1 | |
fi | |
rm -rf docs/javadoc/"$project_version" 2>/dev/null | |
cp -r target/reports/"$project_version"/apidocs docs/javadoc/"$project_version" | |
template=$(<docs-scripts/latest-template.html) | |
output="${template//\{project_version\}/$project_version}" | |
echo -e "$output" > docs/javadoc/latest/index.html | |
- name: install python packages | |
run: pip install -r ./docs-scripts/requirements.txt | |
- name: build docs | |
run: python ./docs-scripts/build.py | |
- name: commit files | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add -f docs/ | |
git commit -m "update docs" -a | |
- name: push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |