Publish automatically JavaDoc: with GitHub Actions

Viewed 330

Introduction

I am currently working on a Java Maven project in GitHub, and I'm building a JavaDoc and posting it to a GitHub page.

Question

And I was wondering if it would be possible to automate this with a GitHub Actions, if so how?

1 Answers

JavaDoc publisher

Yes is possible, with this code on your GitHub Actions :

name: Deploy Javadoc

on:
  push:
    branches:
      - master
      - main

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy JavaDoc 
        uses: MathieuSoysal/Javadoc-publisher.yml@v2.0.4
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          javadoc-branch: javadoc
          java-version: 17
          target-folder: javadoc 

Credit: https://github.com/MathieuSoysal/Javadoc-publisher.yml https://github.com/marketplace/actions/deploy-javadoc

This code publish JavaDoc automatically when you publish to "master" branch, your JavaDoc is pushed on javadoc branch, and deployed with GitHub Page.

don't forget to enable GitHub page on your GitHub repo settings


Create a GitHub Actions

To create a GitHub Actions you need to simply, add this yaml file on /.github/workflows/your-file.yaml inside your GitHub repository.

Related