Repository navigation
128 lines (111 loc) · 3.68 KB
/
Copy pathdocs.yml
File metadata and controls
128 lines (111 loc) · 3.68 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
name: Docs
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize, closed]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
pull-requests: write
concurrency:
group: pages
cancel-in-progress: false
env:
BUILD_OUTPUT_DIR: docs/.vitepress/dist
PREVIEW_DIR: pr-preview
jobs:
build:
name: Build documentation
if: github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Production is served from the custom domain root (base "/").
# PR previews are served from /pr-preview/pr-N/ — VitePress bakes the
# base in at build time, so each event type builds with its own base.
- name: Build with VitePress (production base)
if: github.event_name != 'pull_request'
run: pnpm docs:build
- name: Build with VitePress (PR preview base)
if: github.event_name == 'pull_request'
run: pnpm docs:build
env:
DOCS_BASE: /pr-preview/pr-${{ github.event.pull_request.number }}/
# Hand the build to the deploy job via artifact
- name: Upload docs artifact
uses: actions/upload-artifact@v6
with:
name: docs-build
path: ${{ env.BUILD_OUTPUT_DIR }}
# Production: push the built site to the ROOT of gh-pages, keeping the
# pr-preview/ folder untouched (clean-exclude). GitHub Pages serves the
# gh-pages branch at the custom domain.
deploy-production:
name: Deploy production docs
if: github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Download docs artifact
uses: actions/download-artifact@v7
with:
name: docs-build
path: ${{ env.BUILD_OUTPUT_DIR }}
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ env.BUILD_OUTPUT_DIR }}
clean: true
clean-exclude: |
pr-preview/**
# PR preview: deploy to gh-pages under pr-preview/pr-{number}/ and comment
# the URL on the PR. Preview URL:
# https://strapi.fbritoferreira.com/pr-preview/pr-{number}/
deploy-pr-preview:
name: Deploy PR preview
# On close, build is skipped; still run so the action removes the preview.
if: github.event_name == 'pull_request' && !cancelled() && !failure()
needs: build
runs-on: ubuntu-latest
steps:
# The preview action pushes to gh-pages via git, so the repo must exist.
- name: Checkout
uses: actions/checkout@v7
- name: Download preview artifact
if: github.event.action != 'closed'
uses: actions/download-artifact@v7
with:
name: docs-build
path: ${{ env.BUILD_OUTPUT_DIR }}
# The action nests each preview as {umbrella-dir}/pr-{number}, which
# matches the DOCS_BASE the preview was built with.
- name: Deploy PR preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ${{ env.BUILD_OUTPUT_DIR }}
preview-branch: gh-pages
umbrella-dir: ${{ env.PREVIEW_DIR }}
pages-base-url: strapi.fbritoferreira.com
wait-for-pages-deployment: true
action: auto