From 52998c42d8d9184b0817a697a18af320155e83ee Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 00:33:53 +0800 Subject: [PATCH 1/8] WIP: Publish Dokka HTML docs to project site See https://github.com/oshai/kotlin-logging/issues/382 --- .github/workflows/github-pages.yml | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/github-pages.yml diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml new file mode 100644 index 00000000..59ca4bf6 --- /dev/null +++ b/.github/workflows/github-pages.yml @@ -0,0 +1,79 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: Deploy to GitHub Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +env: + DOKKA_ARTIFACT_NAME: dokka-html + +jobs: + api-docs: + name: Generate Dokka HTML docs + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Configure JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 11 + - name: Generate Dokka HTML docs + run: ./gradlew :dokkaHtml + - name: Upload Dokka output + uses: actions/upload-artifact@v4 + with: + name: ${{ env.DOKKA_ARTIFACT_NAME }} + path: build/dokka/html + if-no-files-found: error + # Build job + build: + runs-on: ubuntu-latest + needs: api-docs + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + - name: Download Dokka artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.DOKKA_ARTIFACT_NAME }} + path: ./_site/api + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 From e2f2997aaf99256d8306e23e3a3b0f50e89b9dd1 Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 00:35:07 +0800 Subject: [PATCH 2/8] [DNM] Test publishing from branch --- .github/workflows/github-pages.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 59ca4bf6..eb437fa9 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -4,7 +4,8 @@ name: Deploy to GitHub Pages on: # Runs on pushes targeting the default branch push: - branches: ["master"] + # TODO: Remove + #branches: ["master"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 1afe8e00f5f3e2822a93e5cfa9732d3880621032 Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 00:36:05 +0800 Subject: [PATCH 3/8] Add names to build + deploy jobs --- .github/workflows/github-pages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index eb437fa9..b373ae1d 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -47,6 +47,7 @@ jobs: if-no-files-found: error # Build job build: + name: Build Jekyll docs runs-on: ubuntu-latest needs: api-docs steps: @@ -69,6 +70,7 @@ jobs: # Deployment job deploy: + name: Deploy to GitHub Pages environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} From f0bfe294162ca135e748b9d608a4b7f9beaa5bfc Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 00:38:34 +0800 Subject: [PATCH 4/8] Use macOS runner for API docs job --- .github/workflows/github-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index b373ae1d..f1bddb86 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -28,7 +28,7 @@ env: jobs: api-docs: name: Generate Dokka HTML docs - runs-on: ubuntu-latest + runs-on: macos-latest # For Kotlin/Native steps: - name: Checkout uses: actions/checkout@v4 From 8b12326343ac20733786a0d49e5ced29d0b98cdf Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 00:58:46 +0800 Subject: [PATCH 5/8] Use custom destination Workaround for https://github.com/actions/jekyll-build-pages/issues/101 --- .github/workflows/github-pages.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index f1bddb86..461d9471 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -23,6 +23,7 @@ concurrency: cancel-in-progress: false env: + JEKYLL_OUTPUT_DIR: ./dist DOKKA_ARTIFACT_NAME: dokka-html jobs: @@ -53,18 +54,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + # Workaround for https://github.com/actions/jekyll-build-pages/issues/101 + - name: Create output directory + run: mkdir ${{ env.JEKYLL_OUTPUT_DIR }} + # We need to run this before the Jekyll site is built, otherwise we get + # a permission denied error - see https://github.com/actions/jekyll-build-pages/issues/101 + - name: Download Dokka artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.DOKKA_ARTIFACT_NAME }} + path: ${{ env.JEKYLL_OUTPUT_DIR }}/api - name: Setup Pages uses: actions/configure-pages@v4 - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: source: ./ - destination: ./_site - - name: Download Dokka artifact - uses: actions/download-artifact@v4 - with: - name: ${{ env.DOKKA_ARTIFACT_NAME }} - path: ./_site/api + destination: ${{ env.JEKYLL_OUTPUT_DIR }} - name: Upload artifact uses: actions/upload-pages-artifact@v2 From 6e36686354157de831b9f9e45f5f73432800c7c1 Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 01:10:42 +0800 Subject: [PATCH 6/8] Specify explicit path (again) --- .github/workflows/github-pages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 461d9471..45e019fe 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -73,6 +73,8 @@ jobs: destination: ${{ env.JEKYLL_OUTPUT_DIR }} - name: Upload artifact uses: actions/upload-pages-artifact@v2 + with: + path: ${{ env.JEKYLL_OUTPUT_DIR }} # Deployment job deploy: From 0230adaaddedc022fee5ae4cad281581494ceea1 Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 01:37:15 +0800 Subject: [PATCH 7/8] Move back download to after Jekyll site is built Remove checkout action as well --- .github/workflows/github-pages.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 45e019fe..711f9509 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -52,18 +52,9 @@ jobs: runs-on: ubuntu-latest needs: api-docs steps: - - name: Checkout - uses: actions/checkout@v4 # Workaround for https://github.com/actions/jekyll-build-pages/issues/101 - name: Create output directory run: mkdir ${{ env.JEKYLL_OUTPUT_DIR }} - # We need to run this before the Jekyll site is built, otherwise we get - # a permission denied error - see https://github.com/actions/jekyll-build-pages/issues/101 - - name: Download Dokka artifact - uses: actions/download-artifact@v4 - with: - name: ${{ env.DOKKA_ARTIFACT_NAME }} - path: ${{ env.JEKYLL_OUTPUT_DIR }}/api - name: Setup Pages uses: actions/configure-pages@v4 - name: Build with Jekyll @@ -71,6 +62,11 @@ jobs: with: source: ./ destination: ${{ env.JEKYLL_OUTPUT_DIR }} + - name: Download Dokka artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.DOKKA_ARTIFACT_NAME }} + path: ${{ env.JEKYLL_OUTPUT_DIR }}/api - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: From 6a8891a52ea1a4372a8a7b9fa483f7ee0c522795 Mon Sep 17 00:00:00 2001 From: Edric Date: Sat, 23 Dec 2023 01:48:32 +0800 Subject: [PATCH 8/8] Revert "[DNM] Test publishing from branch" This reverts commit e2f2997aaf99256d8306e23e3a3b0f50e89b9dd1. --- .github/workflows/github-pages.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 711f9509..1830ff5b 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -4,8 +4,7 @@ name: Deploy to GitHub Pages on: # Runs on pushes targeting the default branch push: - # TODO: Remove - #branches: ["master"] + branches: ["master"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: