docs: add documentation index #18
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 DocC | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| - name: Set up Swift | |
| uses: swift-actions/setup-swift@v2 | |
| with: | |
| swift-version: '6.2' | |
| - name: Build DocC | |
| run: | | |
| set -euo pipefail | |
| output_root="${GITHUB_WORKSPACE}/_site" | |
| rm -rf "${output_root}" | |
| mkdir -p "${output_root}" | |
| docc convert "wrkstrm.docc" \ | |
| --output-path "${output_root}" \ | |
| --transform-for-static-hosting \ | |
| --hosting-base-path / | |
| # Documentation index fallback (only when DocC didn't generate it). | |
| if [ -f "documentation/index/index.html" ] && [ ! -f "${output_root}/documentation/index/index.html" ]; then | |
| mkdir -p "${output_root}/documentation/index" | |
| cp "documentation/index/index.html" "${output_root}/documentation/index/index.html" | |
| fi | |
| # Root landing should go to the documentation index. | |
| echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/documentation/index/"></head></html>' > "${output_root}/index.html" | |
| touch "${output_root}/.nojekyll" | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| deploy: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| needs: build | |
| runs-on: ${{ matrix.os }} | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }}documentation/index/ | |
| steps: | |
| - name: Deploy | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Print Deployed URL | |
| run: echo "Deployed to ${{ steps.deployment.outputs.page_url }}documentation/index/" |