Publish Documentation Site #79
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: Publish Documentation Site | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| main-ref: | |
| description: 'Main Workflow repo ref to publish' | |
| default: 'main' | |
| required: true | |
| kotlin-ref: | |
| description: 'Kotlin Git ref to publish' | |
| default: 'main' | |
| required: true | |
| docs-branch: | |
| description: 'Branch name for updated documentation to be published' | |
| required: true | |
| jobs: | |
| build-docs: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Check out main repo | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ github.event.inputs.main-ref }} | |
| path: 'workflow' | |
| - name: Check out Kotlin repo | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: 'square/workflow-kotlin' | |
| ref: ${{ github.event.inputs.kotlin-ref }} | |
| path: 'workflow-kotlin' | |
| # Docs dependencies | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.12.3' | |
| - name: Install Python dependencies | |
| run: | | |
| cd workflow | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v2 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 17 | |
| # Build Kotlin docs | |
| - name: Build Kotlin docs | |
| run: | | |
| cd workflow-kotlin | |
| ./gradlew assemble --build-cache --quiet | |
| ./gradlew siteDokka --build-cache --quiet | |
| mkdir -p ../workflow/docs/kotlin/api | |
| mv build/dokka/htmlMultiModule ../workflow/docs/kotlin/api | |
| # Generate the mkdocs site | |
| - name: Generate site with mkdocs | |
| env: | |
| WORKFLOW_GOOGLE_ANALYTICS_KEY: ${{ secrets.WORKFLOW_GOOGLE_ANALYTICS_KEY }} | |
| run: | | |
| cd workflow | |
| echo "Building documentation site" | |
| mkdocs build | |
| # Push docs to new branch | |
| - name: Create new docs branch | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: gh-pages | |
| path: 'workflow-publish' | |
| - name: Commit updated docs | |
| run: | | |
| # Get the source repo SHAs | |
| KOTLIN_REF=$(git --git-dir workflow-kotlin/.git log -1 --format='%H') | |
| cd workflow-publish | |
| git checkout -b ${{ github.event.inputs.docs-branch }} | |
| # Copy all the files over from the 'site' directory | |
| cp -R ../workflow/site/* . | |
| # Commit and push | |
| git add . | |
| git commit -m "Update documentation" -m "Docs built from square/workflow-kotlin@$KOTLIN_REF" | |
| git push origin HEAD:${{ github.event.inputs.docs-branch }} |