Skip to content

Commit 6ca8d02

Browse files
author
abrulic
committed
check
1 parent c784051 commit 6ca8d02

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,51 @@ jobs:
4545
run: pnpm run test
4646

4747
build-docs:
48-
if: ${{ github.event_name == 'pull_request' }}
49-
name: Build Docs
5048
runs-on: ubuntu-latest
5149
steps:
52-
- name: Checkout
53-
uses: actions/checkout@v4
50+
- uses: actions/checkout@v4
5451
with:
55-
# checkout the PR head branch
5652
ref: ${{ github.head_ref }}
5753
fetch-depth: 0
5854

59-
- name: Setup pnpm
60-
uses: pnpm/action-setup@v4
61-
62-
- name: Setup Node
63-
uses: actions/setup-node@v4
55+
- uses: pnpm/action-setup@v4
56+
- uses: actions/setup-node@v4
6457
with:
6558
node-version-file: "package.json"
6659
cache: pnpm
6760

68-
- name: Install deps
61+
# One install at the workspace root is enough
62+
- name: Install deps (root)
6963
run: pnpm install --prefer-offline --frozen-lockfile
7064

65+
# Decide where the docs app lives: ./docs or .
66+
- name: Resolve DOCS_DIR
67+
id: paths
68+
shell: bash
69+
run: |
70+
if [ -d docs ] && [ -f docs/package.json ]; then
71+
DOCS_DIR="docs"
72+
else
73+
DOCS_DIR="."
74+
fi
75+
76+
# expose for later steps
77+
echo "DOCS_DIR=$DOCS_DIR" >> "$GITHUB_OUTPUT"
78+
79+
# ok to print within this step using the shell variable
80+
echo "Using DOCS_DIR=$DOCS_DIR"
81+
7182
- name: Generate docs
72-
#FIXME uncomment this if you use inside another repo
73-
# working-directory: docs
7483
env:
7584
APP_ENV: production
76-
run: pnpm run generate:docs
85+
run: pnpm -C "${{ steps.paths.outputs.DOCS_DIR }}" run generate:docs
7786

7887
- name: Pack generated docs (tarball)
7988
run: |
80-
tar -czf docs-generated.tgz -C docs generated-docs
89+
OUT_BASE="${{ steps.paths.outputs.DOCS_DIR }}"
90+
tar -czf docs-generated.tgz -C "$OUT_BASE" generated-docs
8191
ls -lh docs-generated.tgz
92+
8293
- name: Upload generated docs (tgz)
8394
uses: actions/upload-artifact@v4
8495
with:
@@ -90,7 +101,7 @@ jobs:
90101
uses: actions/upload-artifact@v4
91102
with:
92103
name: docs-versions
93-
path: docs/app/utils/versions.ts
104+
path: ${{ steps.paths.outputs.DOCS_DIR }}/app/utils/versions.ts
94105
if-no-files-found: error
95106

96107
deploy-docs-pr-preview:

scripts/generate-docs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const resetDir = (p: string) => {
3232
}
3333

3434
const contentDir = "content"
35-
const outputDir = "generated-docs"
35+
const docsRoot = findDocsWorkspace(process.cwd())
36+
const outputDir = resolve(docsRoot, "generated-docs")
3637
const APP_ENV = getServerEnv().APP_ENV
3738
// Auto-detect a docs workspace: prefer CWD if it contains `content/`, otherwise try ./docs
3839
function findDocsWorkspace(start: string) {
@@ -49,7 +50,6 @@ function findDocsWorkspace(start: string) {
4950
throw new Error(`Could not locate docs workspace. Tried '.' and './docs'. `)
5051
}
5152

52-
const docsRoot = findDocsWorkspace(process.cwd())
5353
const currentDocsWorkspace = docsRoot
5454

5555
let docsRelative = ""
@@ -257,7 +257,7 @@ function isPullRequestCI() {
257257
}
258258

259259
// Write versions file for the app
260-
const versionsFile = resolve("app/utils/versions.ts")
260+
const versionsFile = resolve(docsRoot, "app/utils/versions.ts")
261261
writeFileSync(
262262
versionsFile,
263263
`// Auto-generated file. Do not edit manually.

0 commit comments

Comments
 (0)