I am currently working on a Java project in GitHub and I need on every update to manually generate JavaDoc and upload it on GitHub Page. But it’s very tedious.
And I wondering if is possible to automatise this with a CI?
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.3.2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: javadoc
java-version: 17
target-folder: javadoc
project: maven # or gradle
Credit: https://github.com/MathieuSoysal/Javadoc-publisher.yml https://github.com/marketplace/actions/deploy-javadoc
This code publishes JavaDoc automatically when you publish your code 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
To create a GitHub Actions you need to simply add this yaml file on /.github/workflows/<your-file>.yaml
inside your GitHub repository.