@@ -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 :
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 :
0 commit comments