Deploy Multi-Docs #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Multi-Docs | |
| on: | |
| workflow_run: | |
| workflows: [ "Publish Release" ] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required to fetch tags for versioning | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Get latest tag | |
| id: vars | |
| run: | | |
| # Finds the latest tag, defaults to 'latest' if no tags are found | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") | |
| echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| with: | |
| cache-read-only: false | |
| cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_CACHE_KEY }} | |
| - name: cache kotlin-konan | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.konan | |
| key: ${{ runner.os }}-kotlin-konan | |
| - name: Build Dokka (API Reference) | |
| run: ./gradlew dokkaGenerateHtml -PprojectVersion=${{ steps.vars.outputs.tag }} -PonlyDocs | |
| - name: Inject Environment Variables | |
| run: | | |
| sed -i "s/__VERSION_PLACEHOLDER__/${{ steps.vars.outputs.tag }}/g" doc/Writerside/v.list | |
| - name: Build Writerside (User Guide) | |
| uses: JetBrains/writerside-github-action@v4 | |
| with: | |
| project-path: 'doc/Writerside' | |
| instance: 'Writerside/kni' | |
| artifact-name: 'web-help' | |
| env: | |
| # Injects the version into Writerside's %latest_version% variable (defined in v.list) | |
| INSTANCE_LATEST_VERSION: ${{ steps.vars.outputs.tag }} | |
| - name: Setup Staging Area | |
| shell: bash | |
| run: | | |
| mkdir -p staging/api | |
| mkdir -p temp_extract | |
| touch staging/.nojekyll | |
| unzip -oq "artifacts/*KNI*.zip" -d temp_extract | |
| INDEX_PATH=$(find temp_extract -name "index.html" | head -n 1) | |
| if [ -z "$INDEX_PATH" ]; then | |
| echo "Error: index.html not found in any extracted files!" | |
| ls -R temp_extract | |
| exit 1 | |
| fi | |
| INDEX_DIR=$(dirname "$INDEX_PATH") | |
| cp -r "$INDEX_DIR"/* staging/ | |
| cp -r jni/build/dokka/html/* staging/api/jni/ | |
| cp -r buffers/build/dokka/html/* staging/api/buffers/ | |
| echo "Final Staging Structure:" | |
| ls -F staging | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: staging | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |