Skip to content

Commit

Permalink
Update docs and actually bump to 0.47
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Oct 23, 2023
1 parent b16a5ac commit 4913124
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy

on:
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build Docs
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
& .\PwshSpectreConsole\Build.ps1
Install-Module HelpOut -Scope CurrentUser -Force
& .\PwshSpectreConsole.Docs\UpdateDocs.ps1 -NonInteractive
git config --global user.name 'Shaun Lawrie (via GitHub Actions)'
git config --global user.email '[email protected]'
git add .\PwshSpectreConsole.Docs\src\content
git commit -m "[skip ci] Update docs"
git push
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: "./PwshSpectreConsole.Docs/dist"
command: pages deploy --project-name pwshspectreconsole --commit-dirty=true --branch=main
23 changes: 15 additions & 8 deletions PwshSpectreConsole.Docs/UpdateDocs.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#requires -Modules HelpOut
param(
[switch]$NonInteractive
)

$ErrorActionPreference = "Stop"

Import-Module "..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force
Remove-Item -Recurse -Path ".\src\content\docs\reference\*" -Force
Get-Module PwshSpectreConsole | Save-MarkdownHelp -OutputPath ".\src\content\docs\reference\" -IncludeYamlHeader -YamlHeaderInformationType Metadata -ExcludeFile "*.gif", "*.png"
Import-Module "$PSScriptRoot\..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force
Remove-Item -Recurse -Path "$PSScriptRoot\src\content\docs\reference\*" -Force
Get-Module PwshSpectreConsole | Save-MarkdownHelp -OutputPath "$PSScriptRoot\src\content\docs\reference\" -IncludeYamlHeader -YamlHeaderInformationType Metadata -ExcludeFile "*.gif", "*.png"

# Post-processing for astro stuff
$groups = @(
Expand All @@ -16,7 +19,7 @@ $groups = @(
@{ Name = "Config"; Matches = @("set-") }
)
$remove = @("Start-SpectreDemo.md")
$docs = Get-ChildItem ".\src\content\docs\reference\" -Filter "*.md" -Recurse
$docs = Get-ChildItem "$PSScriptRoot\src\content\docs\reference\" -Filter "*.md" -Recurse
foreach($doc in $docs) {
if($remove -contains $doc.Name) {
Remove-Item $doc.FullName
Expand All @@ -33,18 +36,22 @@ foreach($doc in $docs) {
}
}

$outLocation = ".\src\content\docs\reference\$($group.Name)\$($doc.Name)"
$outLocation = "$PSScriptRoot\src\content\docs\reference\$($group.Name)\$($doc.Name)"
if($null -eq $group) {
$outLocation = $doc.FullName
}
New-Item -ItemType Directory -Path ".\src\content\docs\reference\$($group.Name)" -Force | Out-Null
New-Item -ItemType Directory -Path "$PSScriptRoot\src\content\docs\reference\$($group.Name)" -Force | Out-Null
$content = Get-Content $doc.FullName -Raw
Remove-Item $doc.FullName
$content -replace '```PowerShell', '```powershell' -replace '(?m)^.+\n^[\-]{10,99}', '' | Out-File $outLocation
}

# Build the docs site
npm run build --prefix .\
npm run build --prefix $PSScriptRoot

if($NonInteractive) {
return
}

# Yeet it to cloudflare
$choice = Read-Host "`nDeploy to CF pages? (y/n)"
Expand All @@ -54,5 +61,5 @@ if($choice -eq "y") {
} else {
npx wrangler login
}
npx wrangler pages deploy .\dist --project-name pwshspectreconsole --commit-dirty=true --branch=main
npx wrangler pages deploy "$PSScriptRoot\dist" --project-name pwshspectreconsole --commit-dirty=true --branch=main
}
2 changes: 1 addition & 1 deletion PwshSpectreConsole/Build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
param (
[string] $Version = "0.46.0"
[string] $Version = "0.47.0"
)

function Install-SpectreConsole {
Expand Down

0 comments on commit 4913124

Please sign in to comment.