To publish your documentation to GitHub Pages after generating it via Dokka (Kotlin), follow these steps:
- Add Dokka to project
build.gradle.kts
- Add Github Action
- Enable Github Pages for your repository
- Project -> Settings -> Pages tab
- Source:
Deploy from a branch
- Branch:
gh-pages
- Run the Github Action
plugins {
id("org.jetbrains.dokka") version "1.9.10"
}
tasks{
register<Jar>("dokkaJar") {
from(dokkaHtml)
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
}
}
name: Docs
on:
push:
branches: [ main ]
## Delete below when merged to main!
## Added such that one can test pages deployment on branch before merging
pull_request:
branches: [ main ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'adopt'
- name: Build documentation
run: ./gradlew dokkaHtml
- name: Publish documentation
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
BRANCH: gh-pages
FOLDER: build/dokka/html
To publish the documentation, run the Github Action. It will generate the Dokka site, copy it to the gh-pages
branch, and publish it to https://{userid}.github.io/{repo_name}
.
Here are some additional resources that you may find helpful: