Skip to content

Commit 33b21a9

Browse files
authored
feat(docs): deploy main branch preview alongside PR previews (#707)
## Summary - Extend the docs-preview workflow to also trigger on pushes to `main`, deploying a continuously-updated preview to `_preview/pr-main/` on `gh-pages` - Rename the umbrella directory from `pr-preview` to `_preview` - Scope concurrency per-ref (`docs-preview-${{ github.ref }}`) with `cancel-in-progress: true` ## Details Production deploys via Craft remain unchanged. This adds a `main` branch preview so merged docs changes are immediately viewable at `cli.sentry.dev/_preview/pr-main/` without waiting for a release. The workflow reuses `rossjrw/pr-preview-action` for both cases with conditional inputs: - **Push to main**: `action: deploy`, `pr-number: main`, `comment: false` - **PR events**: `action: auto` (unchanged behavior) The astro config's landing page regex is updated to match the new `_preview` path and the `main` preview. Old `pr-preview/` directory on `gh-pages` is left as-is (harmless, will be cleaned up by future Craft releases).
1 parent ac7e9e0 commit 33b21a9

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

.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)