Skip to content

Commit 71fca43

Browse files
committed
try new build sequence
1 parent 629f53f commit 71fca43

2 files changed

Lines changed: 75 additions & 2 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build & Deploy MkDocs to Vercel
2+
3+
# ──────────────────────────────────────────────────────────────
4+
# Triggers
5+
# • Push to *any* branch → preview (unless it's main)
6+
# • Pull request (any branch) → preview
7+
# • Push to main → production
8+
# ──────────────────────────────────────────────────────────────
9+
on:
10+
push: # all branches
11+
pull_request: # previews for PRs
12+
workflow_dispatch: # manual trigger
13+
14+
jobs:
15+
build-deploy:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
# 1️⃣ Check out code
20+
- uses: actions/checkout@v4
21+
22+
# 2️⃣ Set up Python & cache pip
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.11"
26+
27+
- name: Cache pip
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-pip-${{ hashFiles('source/requirements.txt') }}
32+
restore-keys: ${{ runner.os }}-pip-
33+
34+
# 3️⃣ Install MkDocs + plugins
35+
- name: Install MkDocs dependencies
36+
run: pip install -r source/requirements.txt
37+
38+
# 4️⃣ Build the docs → site/
39+
- name: Build MkDocs site
40+
run: mkdocs build -f source/mkdocs.yml -d site
41+
42+
# 5️⃣ Set up Node (for Vercel CLI)
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: "20"
46+
47+
- name: Install Vercel CLI
48+
run: npm i -g vercel@latest
49+
50+
# 6️⃣ Pull Vercel project settings (separate envs)
51+
- name: Pull Vercel metadata
52+
env:
53+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
54+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
55+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
56+
# Use preview env except on main
57+
run: |
58+
if [ "${{ github.ref_name }}" = "main" ]; then
59+
vercel pull --yes --environment=production --token $VERCEL_TOKEN
60+
else
61+
vercel pull --yes --environment=preview --token $VERCEL_TOKEN
62+
fi
63+
64+
# 7️⃣ Deploy (preview or prod)
65+
- name: Deploy to Vercel
66+
env:
67+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
68+
run: |
69+
# Deploy pre-built static output in site/
70+
if [ "${{ github.ref_name }}" = "main" ]; then
71+
vercel deploy --prebuilt --prod --token $VERCEL_TOKEN site
72+
else
73+
vercel deploy --prebuilt --token $VERCEL_TOKEN site
74+
fi

vercel.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"buildCommand": "pip install -r source/requirements.txt && mkdocs build -f source/mkdocs.yml -d site",
32
"outputDirectory": "site"
4-
}
3+
}

0 commit comments

Comments
 (0)