Skip to content

Commit cca6856

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 ac7e9e0 commit cca6856

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.github/workflows/docs-preview.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
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+
- 'install'
12+
- '.github/workflows/docs-preview.yml'
413
pull_request:
514
paths:
615
- 'docs/**'
@@ -14,6 +23,10 @@ permissions:
1423
contents: write
1524
pull-requests: write
1625

26+
concurrency:
27+
group: docs-preview-${{ github.ref }}
28+
cancel-in-progress: true
29+
1730
jobs:
1831
preview:
1932
runs-on: ubuntu-latest
@@ -41,8 +54,9 @@ jobs:
4154
- name: Build Docs for Preview
4255
working-directory: docs
4356
env:
44-
# Override base path for PR preview (no /cli prefix since preview domain is different)
45-
DOCS_BASE_PATH: /pr-preview/pr-${{ github.event.pull_request.number }}
57+
DOCS_BASE_PATH: ${{ github.event_name == 'push'
58+
&& '/_preview/pr-main'
59+
|| format('/_preview/pr-{0}', github.event.pull_request.number) }}
4660
PUBLIC_SENTRY_ENVIRONMENT: staging
4761
SENTRY_RELEASE: ${{ steps.version.outputs.version }}
4862
PUBLIC_SENTRY_RELEASE: ${{ steps.version.outputs.version }}
@@ -102,6 +116,8 @@ jobs:
102116
with:
103117
source-dir: docs/dist/
104118
preview-branch: gh-pages
105-
umbrella-dir: pr-preview
119+
umbrella-dir: _preview
106120
pages-base-url: cli.sentry.dev
107-
action: auto
121+
action: ${{ github.event_name == 'push' && 'deploy' || 'auto' }}
122+
pr-number: ${{ github.event_name == 'push' && 'main' || github.event.pull_request.number }}
123+
comment: ${{ github.event_name != 'push' }}

docs/astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default defineConfig({
8282
const path = window.location.pathname;
8383
// Works with both / (prod) and /pr-preview/pr-XX (preview)
8484
return path === '/' ||
85-
/^\\/pr-preview\\/pr-\\d+\\/?$/.test(path);
85+
/^\\/_preview\\/pr-(\\d+|main)\\/?$/.test(path);
8686
}
8787
8888
function checkAtBottom() {

0 commit comments

Comments
 (0)