Notification texts go here Contact Us Buy Now!

How Can I publish the Docs to Github pages after generating it via Dokka (Kotlin)?

To publish your documentation to GitHub Pages after generating it via Dokka (Kotlin), follow these steps:

  1. Add Dokka to project build.gradle.kts
  2. plugins {
        id("org.jetbrains.dokka") version "1.9.10"
    }
    
    tasks{
        register<Jar>("dokkaJar") {
            from(dokkaHtml)
            dependsOn(dokkaHtml)
            archiveClassifier.set("javadoc")
        }
    }
    
    
  3. Add Github Action
  4. 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
    
    
  5. Enable Github Pages for your repository
    • Project -> Settings -> Pages tab
    • Source: Deploy from a branch
    • Branch: gh-pages
  6. Run the Github Action
  7. 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:

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.