Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 78 additions & 2 deletions .github/workflows/build-website.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Validates that the Docusaurus website builds successfully.
# Runs on PRs that modify website files, and can also be called from other
# workflows or triggered manually.
# Runs on PRs that modify website files or docs source files, and can also be
# called from other workflows or triggered manually.
name: "\U0001F3D7️ Build Website"

on:
Expand All @@ -20,6 +20,9 @@ on:
pull_request:
branches: ["main"]
paths:
- "build/Update-CommandReference.ps1"
- "powershell/**"
- "tests/**"
- "website/**"
- ".github/workflows/build-website.yaml"

Expand All @@ -28,17 +31,90 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
actions: read
contents: read

jobs:
generate-command-reference:
name: "Generate command reference"
runs-on: windows-latest
permissions:
contents: read

Comment thread
SamErde marked this conversation as resolved.
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Generate command reference
shell: pwsh
run: ./build/Update-CommandReference.ps1

Comment thread
SamErde marked this conversation as resolved.
- name: Package generated command reference
shell: pwsh
run: |
$ProgressPreference = "SilentlyContinue"
$artifactRoot = Join-Path $env:GITHUB_WORKSPACE "generated-command-reference"
$docsRoot = Join-Path $artifactRoot "website/docs"
New-Item -ItemType Directory -Path $docsRoot -Force | Out-Null

$sourceCommands = Join-Path $env:GITHUB_WORKSPACE "website/docs/commands"
if (-not (Test-Path $sourceCommands)) {
throw "Command reference docs were not generated at $sourceCommands."
}

Copy-Item -Path $sourceCommands -Destination $docsRoot -Recurse -Force

$versionedDocsRoot = Join-Path $env:GITHUB_WORKSPACE "website/versioned_docs"
if (Test-Path $versionedDocsRoot) {
foreach ($versionFolder in Get-ChildItem $versionedDocsRoot -Directory) {
$sourceVersionCommands = Join-Path $versionFolder.FullName "commands"
if (Test-Path $sourceVersionCommands) {
$targetVersionRoot = Join-Path $artifactRoot "website/versioned_docs/$($versionFolder.Name)"
New-Item -ItemType Directory -Path $targetVersionRoot -Force | Out-Null
Copy-Item -Path $sourceVersionCommands -Destination $targetVersionRoot -Recurse -Force
}
}
}

Compress-Archive -Path (Join-Path $artifactRoot "*") -DestinationPath command-reference-docs.zip -Force

- name: Upload generated command reference
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: generated-command-reference
path: command-reference-docs.zip
if-no-files-found: error

build:
name: "Build Docusaurus website \U0001F3D7️"
needs: generate-command-reference
runs-on: ubuntu-latest

steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Download generated command reference
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: generated-command-reference
path: ${{ runner.temp }}/command-reference

- name: Apply generated command reference
shell: pwsh
run: |
$ProgressPreference = "SilentlyContinue"
Remove-Item -Path ./website/docs/commands -Recurse -Force -ErrorAction SilentlyContinue

$versionedDocsRoot = "./website/versioned_docs"
if (Test-Path $versionedDocsRoot) {
foreach ($versionFolder in Get-ChildItem $versionedDocsRoot -Directory) {
Remove-Item -Path (Join-Path $versionFolder.FullName "commands") -Recurse -Force -ErrorAction SilentlyContinue
}
}

Expand-Archive -Path "${{ runner.temp }}/command-reference/command-reference-docs.zip" -DestinationPath . -Force

- name: ⚙️ Set up Node.js ${{ inputs.node_version || '24.x' }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
Expand Down
Loading