1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Deploy Docs
on:
push:
branches:
tags:
workflow_dispatch:
inputs:
version:
description: "override the documentation version. leave empty to derive from the dispatched ref."
required: false
default: ""
permissions:
contents: write
concurrency:
group: docs-gh-pages
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
coverage: none
- name: Cache wasm-pack
uses: actions/cache@v4
with:
path: ~/.cargo/bin/wasm-pack
key: wasm-pack-0.13.1-${{ runner.os }}
- name: Build playground WASM
run: |
if ! command -v wasm-pack &>/dev/null; then
cargo install wasm-pack --version 0.13.1 --locked
fi
wasm-pack build crates/wasm --target web --release --out-dir pkg-web
mkdir -p docs/static/playground_wasm
cp crates/wasm/pkg-web/mago_wasm.js \
crates/wasm/pkg-web/mago_wasm_bg.wasm \
crates/wasm/pkg-web/mago_wasm.d.ts \
crates/wasm/pkg-web/mago_wasm_bg.wasm.d.ts \
crates/wasm/pkg-web/package.json \
docs/static/playground_wasm/
- name: Install documentation Node dependencies
run: npm install --prefix docs
- name: Determine documentation version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
shell: bash
run: |
if [[ -n "${INPUT_VERSION}" ]]; then
echo "value=${INPUT_VERSION}" >> "${GITHUB_OUTPUT}"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
echo "value=${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}"
else
echo "value=main" >> "${GITHUB_OUTPUT}"
fi
- name: Build static documentation
env:
MAGO_DOCS_VERSION: ${{ steps.version.outputs.value }}
run: |
cargo run -p mago-documentation
- name: Generate configuration schema
env:
MAGO_DOCS_VERSION: ${{ steps.version.outputs.value }}
run: |
mkdir -p "docs/dist/${MAGO_DOCS_VERSION}"
cargo run --quiet -p mago -- config --schema > "docs/dist/${MAGO_DOCS_VERSION}/schema.json"
- name: Check out existing gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
continue-on-error: true
- name: Initialise gh-pages on first deploy
shell: bash
run: |
set -euo pipefail
if [ ! -d gh-pages/.git ]; then
mkdir -p gh-pages
cd gh-pages
git init -b gh-pages
git remote add origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git"
fi
- name: Stage gh-pages
run: php scripts/publish-docs.php "${{ steps.version.outputs.value }}" docs gh-pages
- name: Commit and push gh-pages
working-directory: gh-pages
shell: bash
run: |
set -euo pipefail
touch .nojekyll
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "deploy: ${{ steps.version.outputs.value }}"
git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" 2>/dev/null \
|| git remote add origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git"
git push origin HEAD:gh-pages --force