|
| 1 | +name: Basalt 2.5 Docs & Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + pages: write |
| 9 | + id-token: write |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: pages |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Generate and build docs |
| 18 | + runs-on: ubuntu-22.04 |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout Basalt 2.5 |
| 22 | + uses: actions/checkout@v6 |
| 23 | + with: |
| 24 | + ref: basalt2.5 |
| 25 | + path: source |
| 26 | + |
| 27 | + - name: Checkout documentation branch |
| 28 | + uses: actions/checkout@v6 |
| 29 | + with: |
| 30 | + ref: gh-pages |
| 31 | + path: site |
| 32 | + |
| 33 | + - name: Install CraftOS-PC |
| 34 | + run: | |
| 35 | + sudo add-apt-repository --yes ppa:jackmacwindows/ppa |
| 36 | + sudo apt-get update |
| 37 | + sudo apt-get install --yes craftos-pc |
| 38 | +
|
| 39 | + - name: Generate Basalt 2.5 API documentation |
| 40 | + run: | |
| 41 | + mkdir -p "$RUNNER_TEMP/craftos-docs" |
| 42 | + mkdir -p "$RUNNER_TEMP/basalt-docs" |
| 43 | + craftos \ |
| 44 | + --headless \ |
| 45 | + --directory "$RUNNER_TEMP/craftos-docs" \ |
| 46 | + --mount-ro "Basalt=$GITHUB_WORKSPACE/source" \ |
| 47 | + --mount-rw "output=$RUNNER_TEMP/basalt-docs" \ |
| 48 | + --exec "local ok=shell.run('Basalt/tools/docgen.lua','output'); os.shutdown(ok and 0 or 1)" |
| 49 | + mv "$RUNNER_TEMP/basalt-docs/README.md" \ |
| 50 | + "$RUNNER_TEMP/basalt-docs/index.md" |
| 51 | +
|
| 52 | + - name: Update versioned documentation |
| 53 | + run: | |
| 54 | + mkdir -p site/docs/2.5/api |
| 55 | + rsync --archive --delete \ |
| 56 | + "$RUNNER_TEMP/basalt-docs/" \ |
| 57 | + site/docs/2.5/api/ |
| 58 | + cp source/.github/docs-2.5-index.md site/docs/2.5/index.md |
| 59 | +
|
| 60 | + - name: Setup Node |
| 61 | + uses: actions/setup-node@v6 |
| 62 | + with: |
| 63 | + node-version: 20 |
| 64 | + package-manager-cache: false |
| 65 | + |
| 66 | + - name: Setup Pages |
| 67 | + uses: actions/configure-pages@v4 |
| 68 | + |
| 69 | + - name: Install VitePress dependencies |
| 70 | + working-directory: site |
| 71 | + run: npm ci |
| 72 | + |
| 73 | + - name: Build VitePress site |
| 74 | + working-directory: site |
| 75 | + run: npm run docs:build |
| 76 | + |
| 77 | + - name: Commit Basalt 2.5 documentation |
| 78 | + working-directory: site |
| 79 | + run: | |
| 80 | + git config user.name "github-actions[bot]" |
| 81 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 82 | + git add docs/2.5 |
| 83 | + if git diff --cached --quiet; then |
| 84 | + echo "Basalt 2.5 documentation is already current." |
| 85 | + else |
| 86 | + git commit -m "docs: update Basalt 2.5 API" |
| 87 | + git push |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Upload Pages artifact |
| 91 | + uses: actions/upload-pages-artifact@v3 |
| 92 | + with: |
| 93 | + path: site/docs/.vitepress/dist |
| 94 | + |
| 95 | + deploy: |
| 96 | + name: Deploy to GitHub Pages |
| 97 | + needs: build |
| 98 | + runs-on: ubuntu-latest |
| 99 | + |
| 100 | + environment: |
| 101 | + name: github-pages |
| 102 | + url: ${{ steps.deployment.outputs.page_url }} |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Deploy GitHub Pages |
| 106 | + id: deployment |
| 107 | + uses: actions/deploy-pages@v4 |
0 commit comments