Basalt 2.5 Docs & Deploy #12
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: Basalt 2.5 Docs & Deploy | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Generate and build versioned docs | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout deployment automation | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| path: automation | |
| - name: Checkout Basalt 2.5 | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: basalt2.5 | |
| path: source | |
| - name: Checkout documentation branch | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: gh-pages | |
| path: site | |
| - name: Install CraftOS-PC | |
| run: | | |
| sudo add-apt-repository --yes ppa:jackmacwindows/ppa | |
| sudo apt-get update | |
| sudo apt-get install --yes craftos-pc | |
| - name: Generate Basalt 2.5 API documentation | |
| run: | | |
| mkdir -p "$RUNNER_TEMP/craftos-docs" | |
| mkdir -p "$RUNNER_TEMP/basalt-docs" | |
| craftos \ | |
| --headless \ | |
| --directory "$RUNNER_TEMP/craftos-docs" \ | |
| --mount-ro "Basalt=$GITHUB_WORKSPACE/source" \ | |
| --mount-rw "output=$RUNNER_TEMP/basalt-docs" \ | |
| --exec "local ok=shell.run('Basalt/tools/docgen.lua','output'); os.shutdown(ok and 0 or 1)" | |
| mv "$RUNNER_TEMP/basalt-docs/README.md" \ | |
| "$RUNNER_TEMP/basalt-docs/index.md" | |
| - name: Update Basalt 2.5 documentation source | |
| run: | | |
| mkdir -p site/docs/2.5/api | |
| mkdir -p site/docs/2.5/.vitepress | |
| rsync --archive --delete \ | |
| "$RUNNER_TEMP/basalt-docs/" \ | |
| site/docs/2.5/api/ | |
| cp source/.github/docs-2.5-index.md site/docs/2.5/index.md | |
| cp source/.github/vitepress-2.5.config.mts \ | |
| site/docs/2.5/.vitepress/config.mts | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Install VitePress dependencies | |
| working-directory: site | |
| run: npm ci | |
| - name: Build Basalt 2.0 and 2.5 sites | |
| working-directory: site | |
| run: | | |
| mkdir -p "$RUNNER_TEMP/pages/2.0" | |
| mkdir -p "$RUNNER_TEMP/pages/2.5" | |
| mv docs/.vitepress/config.mts \ | |
| docs/.vitepress/config.base.mts | |
| cp ../automation/.github/vitepress-2.0.config.mts \ | |
| docs/.vitepress/config.mts | |
| npx vitepress build docs \ | |
| --outDir "$RUNNER_TEMP/pages/2.0" | |
| npx vitepress build docs/2.5 \ | |
| --outDir "$RUNNER_TEMP/pages/2.5" | |
| cp ../automation/.github/pages-index.html \ | |
| "$RUNNER_TEMP/pages/index.html" | |
| touch "$RUNNER_TEMP/pages/.nojekyll" | |
| node ../automation/.github/scripts/create-version-redirects.mjs \ | |
| "$RUNNER_TEMP/pages/2.0" \ | |
| "$RUNNER_TEMP/pages" | |
| - name: Commit Basalt 2.5 documentation source | |
| working-directory: site | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add docs/2.5 | |
| if git diff --cached --quiet; then | |
| echo "Basalt 2.5 documentation is already current." | |
| else | |
| git commit -m "docs: update Basalt 2.5 API" | |
| git push | |
| fi | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ${{ runner.temp }}/pages | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |