Skip to content

Commit 342c683

Browse files
committed
feat(docs): deploy main branch preview alongside PR previews
Extend the docs-preview workflow to also trigger on pushes to main, deploying a continuously-updated preview at _preview/pr-main/ on gh-pages. Rename the umbrella directory from pr-preview to _preview. - Add push:main trigger with same path filters as pull_request - Use conditional action inputs (deploy+no comment for main, auto for PRs) - Scope concurrency per-ref with cancel-in-progress - Update astro landing page regex for the new _preview path
1 parent abdc5e4 commit 342c683

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/docs-preview.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Docs Preview
22

33
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- 'src/**'
9+
- 'script/generate-command-docs.ts'
10+
- 'script/generate-skill.ts'
11+
- '.github/workflows/docs-preview.yml'
412
pull_request:
513
paths:
614
- 'docs/**'
@@ -13,6 +21,10 @@ permissions:
1321
contents: write
1422
pull-requests: write
1523

24+
concurrency:
25+
group: docs-preview-${{ github.ref }}
26+
cancel-in-progress: true
27+
1628
jobs:
1729
preview:
1830
runs-on: ubuntu-latest
@@ -36,8 +48,9 @@ jobs:
3648
- name: Build Docs for Preview
3749
working-directory: docs
3850
env:
39-
# Override base path for PR preview (no /cli prefix since preview domain is different)
40-
DOCS_BASE_PATH: /pr-preview/pr-${{ github.event.pull_request.number }}
51+
DOCS_BASE_PATH: ${{ github.event_name == 'push'
52+
&& '/_preview/pr-main'
53+
|| format('/_preview/pr-{0}', github.event.pull_request.number) }}
4154
run: |
4255
bun install --frozen-lockfile
4356
bun run build
@@ -78,6 +91,8 @@ jobs:
7891
with:
7992
source-dir: docs/dist/
8093
preview-branch: gh-pages
81-
umbrella-dir: pr-preview
94+
umbrella-dir: _preview
8295
pages-base-url: cli.sentry.dev
83-
action: auto
96+
action: ${{ github.event_name == 'push' && 'deploy' || 'auto' }}
97+
pr-number: ${{ github.event_name == 'push' && 'main' || github.event.pull_request.number }}
98+
comment: ${{ github.event_name != 'push' }}

docs/astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default defineConfig({
6969
const path = window.location.pathname;
7070
// Works with both / (prod) and /pr-preview/pr-XX (preview)
7171
return path === '/' ||
72-
/^\\/pr-preview\\/pr-\\d+\\/?$/.test(path);
72+
/^\\/_preview\\/pr-(\\d+|main)\\/?$/.test(path);
7373
}
7474
7575
function checkAtBottom() {

0 commit comments

Comments
 (0)