name: Deploy javadocs to GitHub pages

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  pages:
    runs-on: ubuntu-latest
    steps:
      # GET LATEST CODE
      - name: Checkout latest code
        uses: actions/checkout@master
        with:
          fetch-depth: 0

      # BUILD PROJECT AND PUBLISH TO PACKAGES
      - name: Set up JDK 8
        uses: actions/setup-java@v2
        with:
          distribution: 'adopt'
          java-version: '8'
      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
      - name: Build documentation
        run: ./gradlew about build -x test
      - name: List files
        run: ls -ahl build/libs

      # DEPLOY TO GH-PAGES
      - name: Deploy to GitHub-Pages
        uses: JamesIves/github-pages-deploy-action@v4.2.2
        with:
          branch: gh-pages
          folder: build/docs/javadoc
