-
-
Notifications
You must be signed in to change notification settings - Fork 3
135 lines (115 loc) · 4.03 KB
/
Copy pathdocs.yml
File metadata and controls
135 lines (115 loc) · 4.03 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Docs
on:
push:
branches: [develop]
release:
types: [published]
concurrency:
group: docs-deploy
cancel-in-progress: true
env:
NODE_VERSION: "22"
PYTHON_VERSION: "3.14"
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
path: release
- uses: actions/checkout@v6
with:
ref: develop
fetch-depth: 0
path: develop
- name: Determine release ref
id: release-ref
working-directory: release
run: |
if [ "${{ github.event_name }}" = "release" ]; then
REF="${{ github.event.release.tag_name }}"
else
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
REF=$(git tag --list 'v*' --sort=-version:refname | head -1)
REF="${REF:-$DEFAULT_BRANCH}"
fi
echo "ref=${REF}" >> "$GITHUB_OUTPUT"
- name: Checkout release ref
working-directory: release
run: git checkout "${{ steps.release-ref.outputs.ref }}"
- name: Check if release ref has docs
id: check-release-docs
working-directory: release
run: |
if [ -f docs/package.json ] && [ -f docs/.vitepress/config.ts ]; then
echo "has_docs=true" >> "$GITHUB_OUTPUT"
else
echo "has_docs=false" >> "$GITHUB_OUTPUT"
fi
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: |
release/docs/package-lock.json
develop/docs/package-lock.json
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Generate DB layout docs (release)
if: steps.check-release-docs.outputs.has_docs == 'true'
working-directory: release/docs
run: npm run docs:gen-db 2>/dev/null || echo "Skipped — docs:gen-db not in this release"
- name: Build release docs
if: steps.check-release-docs.outputs.has_docs == 'true'
working-directory: release/docs
run: |
npm ci
npx vitepress build
mv .vitepress/dist /tmp/dist-release
- name: Generate DB layout docs (nightly)
working-directory: develop/docs
run: npm run docs:gen-db
- name: Build nightly docs
working-directory: develop/docs
run: |
npm ci
cp .vitepress/config.ts .vitepress/config.original.ts
cp .vitepress/config.nightly.ts .vitepress/config.ts
npx vitepress build
mv .vitepress/dist /tmp/dist-nightly
- name: Prepare full deploy (release + nightly)
if: steps.check-release-docs.outputs.has_docs == 'true'
run: |
mv /tmp/dist-release ./dist
mkdir -p ./dist/next
cp -a /tmp/dist-nightly/. ./dist/next/
- name: Prepare nightly-only deploy
if: steps.check-release-docs.outputs.has_docs != 'true'
run: cp -a /tmp/dist-nightly/. ./dist/
- name: Write version.json
run: |
VERSION="${{ steps.release-ref.outputs.ref }}"
RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/${VERSION}"
printf '{"version":"%s","release_url":"%s"}\n' "$VERSION" "$RELEASE_URL" > ./dist/version.json
- name: Write CNAME
run: |
printf 'docs.librislog.app\n' > ./dist/CNAME
- uses: peaceiris/actions-gh-pages@v4
if: steps.check-release-docs.outputs.has_docs == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
keep_files: false
- uses: peaceiris/actions-gh-pages@v4
if: steps.check-release-docs.outputs.has_docs != 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
destination_dir: next
keep_files: false