# This is a basic workflow to help you get started with Actions

name: mirai-doc Publish

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  release:
    types:
      - created

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  mirai-core-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: chmod -R 777 *
        run: chmod -R 777 *
      - name: Gradle build
        run: ./gradlew clean build # if test's failed, don't publish
      - name: Dokka
        run: ./gradlew :mirai-core-api:dokkaHtml
      - name: GitHub Pages Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.MAMOE_TOKEN }}
          publish_dir: ./mirai-core-api/build/dokka
          external_repository: project-mirai/mirai-doc
          publish_branch: master
          user_name: 'mamoebot'
          user_email: 'mamoebot@users.noreply.github.com'
          keep_files: true

  # This workflow contains a single job called "build"
  mirai-console-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Checkout submodules
        run: git submodule update --init --recursive

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: chmod -R 777 *
        run: chmod -R 777 *
      - name: Gradle build
        run: ./gradlew clean build # if test's failed, don't publish
      - name: Dokka
        run: ./gradlew :mirai-console:dokkaHtml
      - name: GitHub Pages Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.MAMOE_TOKEN }}
          publish_dir: ./mirai-console/build/dokka
          external_repository: project-mirai/mirai-doc
          publish_branch: master
          user_name: 'mamoebot'
          user_email: 'mamoebot@users.noreply.github.com'
          keep_files: true

