Skip to content

Commit 2a6c633

Browse files
authored
Merge pull request #2076 from gregolsky/new-docs
New deployment scripts adjustments
2 parents 32c5bd8 + 54fda2c commit 2a6c633

File tree

6 files changed

+103
-60
lines changed

6 files changed

+103
-60
lines changed

.github/workflows/build-on-pr.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Docusaurus on PR
2+
3+
on:
4+
pull_request:
5+
branches: [new-docs]
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
env:
12+
NODE_OPTIONS: '--max-old-space-size=8192'
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '18'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Build Docusaurus
28+
run: npm run build
29+
30+
- name: Upload build artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: docusaurus-build
34+
path: build/
35+
retention-days: 7
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Deploy to S3 after merge to new-docs
2+
3+
on:
4+
push:
5+
branches: [new-docs]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '18'
19+
cache: 'npm'
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install dependencies
27+
run: npm ci --no-audit --fund false
28+
29+
- name: Run deployment script
30+
shell: pwsh
31+
env:
32+
WHATS_NEW_URL: ${{ secrets.WHATS_NEW_URL }}
33+
AWS_ACCESS_KEY_ID: FAKEKEYID
34+
AWS_SECRET_ACCESS_KEY: FAKEACCESSKEY
35+
AWS_DEFAULT_REGION: us-east-1
36+
run: |
37+
scripts/deploy.ps1 -DryRun -Versions "6.2,7.1" -CloudFrontDistributionId "FAKEDISTID" -S3BucketName "FAKEBUCKET"

docs/whats-new.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pagination_prev: null
66
hide_table_of_contents: true
77
---
88

9-
## 7.1.1 (71007) - 2025/07/22 {#71007}
9+
## 7.1.1 (71007) - 2025/07/22
1010

1111
### Server
1212

@@ -57,9 +57,7 @@ hide_table_of_contents: true
5757
* `[Documents]` Added a confirmation checkbox to the "Delete All Documents" operation to prevent accidental data loss
5858
* `[Edit Document]` The "Copy document ID" button in the document editor is now always visible
5959
* `[Embeddings Generation]` Added info about Quantization + other tooltips
60-
* `[Indexes]` Improved pause/resume indexing in databases view
61-
62-
## 7.1.0 (71005) - 2025/07/01 {#71005}
60+
* `[Indexes]` Improved pause/resume indexing in databases view## 7.1.0 (71005) - 2025/07/01
6361

6462
### Features
6563

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build_whats_new.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
# Configuration & paths
5252
# ============================================================================
5353

54-
API_BASE_URL: str | None = os.environ.get("API_WEB_RAVENDB_NET_HOST") + "/api/v1/documentation/whats-new"
54+
API_BASE_URL: str | None = os.environ.get("WHATS_NEW_URL")
5555

5656
if not API_BASE_URL:
57-
raise EnvironmentError("Environment variable 'API_WEB_RAVENDB_NET_HOST' is not set.")
57+
raise EnvironmentError("Environment variable 'WHATS_NEW_URL' is not set.")
5858

5959
SCRIPT_DIR = Path(__file__).resolve().parent
6060
PROJECT_ROOT = SCRIPT_DIR.parent # «../» relative to /scripts
@@ -70,9 +70,6 @@
7070
"---\n\n"
7171
)
7272

73-
# Regex that replaces markdownify's three‑dash <hr> (---) with MDX‑safe <hr/>
74-
HR_MARKDOWN = re.compile(r"^-{3,}$", re.MULTILINE)
75-
7673
# Date format used by the API – helper for ``datetime.strptime``
7774
API_DATE_FMT = "%m/%d/%Y"
7875

scripts/deploy.ps1

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ Prerequisites
1212
* **Python ≥ 3** (`python` in PATH) – runs the changelog generator
1313
* **AWS CLI v2** – credentials via `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
1414
`AWS_DEFAULT_REGION` (and optional `AWS_SESSION_TOKEN`)
15-
* Environment variable **`API_WEB_RAVENDB_NET_HOST`** set (only required when regenerating
15+
* Environment variable **`WHATS_NEW_URL`** set (only required when regenerating
1616
*What's New* for specific versions)
1717
* Project `package.json` includes `@docusaurus/core` and `@docusaurus/cli`
1818
1919
Example
2020
-------
2121
```powershell
22-
# API_WEB_RAVENDB_NET_HOST must be set if you request specific versions
23-
$env:API_WEB_RAVENDB_NET_HOST = 'YOUR-API-KEY'
22+
# WHATS_NEW_URL must be set if you request specific versions
23+
$env:WHATS_NEW_URL = 'https://whats.new.api/v1/docs'
2424
2525
pwsh deploy.ps1 \
2626
-S3BucketName my-docs-bucket \
2727
-CloudFrontDistributionId ABCD1234 \
28-
-Versions 6.0 6.2 7.0 7.1 8.0
28+
-Versions "6.0,6.2,7.0,7.1,8.0"
2929
```
3030
------------------------------------------------------------------------------!#>
3131

@@ -37,17 +37,14 @@ param(
3737
[Parameter(HelpMessage = 'CloudFront distribution ID to invalidate (optional)')]
3838
[string]$CloudFrontDistributionId,
3939

40-
[Parameter(ValueFromRemainingArguments = $false, HelpMessage = "Versions to regenerate Whats New for e.g. 6.0 7.0 8.0")]
41-
[string[]]$Versions = @(),
40+
[Parameter(HelpMessage = "Comma-separated versions to regenerate Whats New for e.g. '6.0,6.2,7.0'")]
41+
[string]$Versions = "",
4242

4343
[Parameter(HelpMessage = 'Dry run mode. If enabled, no sync to S3 or CloudFront invalidation will occur.')]
4444
[switch]$DryRun
4545
)
4646

47-
# ---------------------------------------------------------------------------
48-
# Constants & helpers
49-
# ---------------------------------------------------------------------------
50-
$PythonWhatsNewPath = Join-Path $PSScriptRoot 'build_whats_new.py' # script lives alongside this file
47+
$PythonWhatsNewPath = Join-Path $PSScriptRoot 'build_whats_new.py'
5148

5249
function ThrowIfEmpty {
5350
param (
@@ -58,7 +55,7 @@ function ThrowIfEmpty {
5855
}
5956

6057
function Ensure-Dependencies {
61-
Write-Host 'Verifying runtime dependencies' -ForegroundColor Cyan
58+
Write-Host 'Verifying runtime dependencies...' -ForegroundColor Cyan
6259

6360
foreach ($cmd in 'node','npm','python','aws') {
6461
if (-not (Get-Command $cmd -ErrorAction SilentlyContinue)) {
@@ -76,59 +73,44 @@ function Ensure-Dependencies {
7673

7774
function Process-Changelogs {
7875
param (
79-
[string[]]$VersionsToBuild
76+
[string[]]$WhatsNewVersions
8077
)
8178

82-
if (-not $VersionsToBuild) { return }
79+
if (-not $WhatsNewVersions) { return }
8380

84-
# Ensure API key exists before invoking Python helper
85-
ThrowIfEmpty $Env:API_WEB_RAVENDB_NET_HOST 'API_WEB_RAVENDB_NET_HOST env var must be set when specifying versions'
81+
ThrowIfEmpty $Env:WHATS_NEW_URL 'WHATS_NEW_URL env var must be set when specifying versions'
8682

87-
Write-Host "Generating *What's New* pages for versions: $($VersionsToBuild -join ', ')" -ForegroundColor Cyan
83+
$VersionsArray = $WhatsNewVersions.Split(',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }
84+
Write-Host "Generating *What's New* pages for versions: $WhatsNewVersions" -ForegroundColor Cyan
8885

89-
& python $PythonWhatsNewPath @VersionsToBuild
86+
& python $PythonWhatsNewPath @VersionsArray
9087
if ($LASTEXITCODE) { throw 'build_whats_new.py failed' }
9188
}
9289

93-
# ---------------------------------------------------------------------------
94-
# 0. Verify runtime dependencies
95-
# ---------------------------------------------------------------------------
9690
Ensure-Dependencies
9791

98-
# ---------------------------------------------------------------------------
99-
# 1. Validate AWS environment
100-
# ---------------------------------------------------------------------------
10192
ThrowIfEmpty $Env:AWS_ACCESS_KEY_ID 'AWS_ACCESS_KEY_ID not set'
10293
ThrowIfEmpty $Env:AWS_SECRET_ACCESS_KEY 'AWS_SECRET_ACCESS_KEY not set'
10394
ThrowIfEmpty $Env:AWS_DEFAULT_REGION 'AWS_DEFAULT_REGION not set'
10495

10596
Write-Host "Region: '$Env:AWS_DEFAULT_REGION' | Bucket: '$S3BucketName'" -ForegroundColor Cyan
10697

107-
# ---------------------------------------------------------------------------
108-
# 2. Validate API_WEB_RAVENDB_NET_HOST when versions are provided
109-
# ---------------------------------------------------------------------------
110-
if ($Versions.Count -gt 0) {
111-
ThrowIfEmpty $Env:API_WEB_RAVENDB_NET_HOST 'API_WEB_RAVENDB_NET_HOST env var must be set when specifying versions'
98+
if ($Versions) {
99+
ThrowIfEmpty $Env:WHATS_NEW_URL 'WHATS_NEW_URL env var must be set when specifying versions'
112100
}
113101

114-
# ---------------------------------------------------------------------------
115-
# 3. Regenerate What's New (if requested)
116-
# ---------------------------------------------------------------------------
117102
Process-Changelogs -VersionsToBuild $Versions
118103

119-
# ---------------------------------------------------------------------------
120-
# 4. Install JS dependencies & build site
121-
# ---------------------------------------------------------------------------
122-
Write-Host 'Installing JS dependencies (npm ci)…' -ForegroundColor Cyan
104+
Write-Host 'Installing JS dependencies (npm ci)...' -ForegroundColor Cyan
123105
$env:NODE_OPTIONS = '--max-old-space-size=8192'
124106

125107
if (-not (Test-Path package.json)) { throw 'package.json not found' }
126108

127109
npm ci --no-audit --fund false
128110
if ($LASTEXITCODE) { throw 'npm ci failed' }
129111

130-
Write-Host "Running 'npx docusaurus build --dev'…" -ForegroundColor Gray
131-
npx docusaurus build --dev
112+
Write-Host "Running 'npx docusaurus build'..." -ForegroundColor Gray
113+
npx docusaurus build
132114
if ($LASTEXITCODE) { throw 'Docusaurus build failed' }
133115

134116
$BuildDir = Join-Path $PSScriptRoot 'build'
@@ -138,16 +120,10 @@ if ($DryRun) {
138120
Write-Host "Dry run mode enabled. Skipping sync to s3://$S3BucketName/ and CloudFront invalidation." -ForegroundColor Yellow
139121
} else {
140122

141-
# ---------------------------------------------------------------------------
142-
# 5. Sync build output to S3
143-
# ---------------------------------------------------------------------------
144-
Write-Host "Syncing to s3://$S3BucketName/ …" -ForegroundColor Cyan
123+
Write-Host "Syncing to s3://$S3BucketName/ ..." -ForegroundColor Cyan
145124
aws s3 sync $BuildDir "s3://$S3BucketName/" --delete
146125
if ($LASTEXITCODE) { throw 'aws s3 sync failed' }
147126

148-
# ---------------------------------------------------------------------------
149-
# 6. Invalidate CloudFront (optional)
150-
# ---------------------------------------------------------------------------
151127
if ($CloudFrontDistributionId) {
152128
Write-Host "Invalidating CloudFront distribution $CloudFrontDistributionId" -ForegroundColor Cyan
153129
aws cloudfront create-invalidation --distribution-id $CloudFrontDistributionId --paths '/*' | Out-Null

0 commit comments

Comments
 (0)