-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (103 loc) · 3.81 KB
/
Copy pathdocs.yml
File metadata and controls
121 lines (103 loc) · 3.81 KB
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
name: Obsidian Docs & Deploy
# Manual only. Publishing to Pages is never triggered by a push; run this
# workflow from the Actions tab when the site should be updated.
on:
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
name: Generate and build documentation
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v6
with:
path: source
# The gh-pages branch holds the VitePress project: package.json, the
# lockfile and docs/. Everything generated is written into it here.
- name: Checkout documentation branch
uses: actions/checkout@v6
with:
ref: gh-pages
path: site
- name: Install Lua
run: |
sudo apt-get update
sudo apt-get install --yes lua5.4
# docgen runs under plain Lua, so no emulator is needed for the docs.
- name: Generate API documentation
working-directory: source
run: |
lua5.4 tools/docgen.lua "$RUNNER_TEMP/obsidian-api"
mv "$RUNNER_TEMP/obsidian-api/README.md" \
"$RUNNER_TEMP/obsidian-api/index.md"
# The whole gh-pages branch is generated from master, scaffolding
# included, so it can start out empty and never needs seeding by hand.
- name: Update documentation source
run: |
mkdir -p site/docs/.vitepress/theme
mkdir -p site/docs/api
mkdir -p site/docs/guides
mkdir -p site/docs/public
rsync --archive --delete \
"$RUNNER_TEMP/obsidian-api/" site/docs/api/
rsync --archive --delete \
source/guides/ site/docs/guides/
cp source/.github/vitepress.config.mts site/docs/.vitepress/config.mts
cp source/.github/theme/index.ts site/docs/.vitepress/theme/index.ts
cp source/.github/theme/custom.css site/docs/.vitepress/theme/custom.css
cp source/.github/docs-index.md site/docs/index.md
cp source/.github/docs-home.md site/docs/home.md
# Served from the site root, so the install command stays short.
cp source/install.lua site/docs/public/install.lua
cp source/.github/site/package.json site/package.json
cp source/.github/site/package-lock.json site/package-lock.json
cp source/.github/site/.gitignore site/.gitignore
touch site/.nojekyll
- 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 site
working-directory: site
run: |
npx vitepress build docs --outDir "$RUNNER_TEMP/pages"
touch "$RUNNER_TEMP/pages/.nojekyll"
- name: Commit 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 package.json package-lock.json .gitignore .nojekyll
if git diff --cached --quiet; then
echo "documentation is already current"
else
git commit -m "docs: update Obsidian 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