Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions .github/actions/Build-PSModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
PSMODULE_BUILD_PSMODULE_INPUT_OutputFolder: ${{ inputs.OutputFolder }}
PSMODULE_BUILD_PSMODULE_INPUT_Version: ${{ inputs.Version }}
PSMODULE_BUILD_PSMODULE_INPUT_Prerelease: ${{ inputs.Prerelease }}
run: |
# Build-PSModule
${{ github.action_path }}/src/main.ps1
run: ${{ github.action_path }}/src/main.ps1

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.

- name: Upload module artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/Build-ZensicalSite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Build-ZensicalSite

Builds Zensical documentation site output and normalizes it to `<working-directory>/_site`.

## Inputs

- `WorkingDirectory` (required): Build working directory.

## Usage

```yaml
- name: Build documentation site with Zensical
uses: ./_wf/.github/actions/Build-ZensicalSite
with:
WorkingDirectory: .
```
16 changes: 16 additions & 0 deletions .github/actions/Build-ZensicalSite/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build-ZensicalSite
description: Build Zensical site output and normalize output folder.

inputs:
WorkingDirectory:
description: Working directory for the repository build.
required: true

runs:
using: composite
steps:
- name: Build documentation site
shell: pwsh
env:
INPUT_WORKING_DIRECTORY: ${{ inputs.WorkingDirectory }}
run: '& "${{ github.action_path }}/src/main.ps1" -WorkingDirectory "$env:INPUT_WORKING_DIRECTORY"'

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
29 changes: 29 additions & 0 deletions .github/actions/Build-ZensicalSite/src/build-zensical-site.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
param(
[Parameter(Mandatory)]
[string]$WorkingDirectory
)

$ErrorActionPreference = 'Stop'

$resolvedWorkingDirectory = Resolve-Path -Path $WorkingDirectory | Select-Object -ExpandProperty Path
$siteWorkingDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath 'outputs/site'
$outputSitePath = Join-Path -Path $resolvedWorkingDirectory -ChildPath '_site'

Set-Location -Path $siteWorkingDirectory

if (-not (Test-Path -Path 'zensical.toml')) {
throw "No documentation config file found in outputs/site. Expected zensical.toml."
}

zensical build --config-file 'zensical.toml'

if (Test-Path -Path '_site') {
if (Test-Path -Path $outputSitePath) {
Remove-Item -Path $outputSitePath -Recurse -Force
}
Move-Item -Path '_site' -Destination $outputSitePath -Force
}

if (-not (Test-Path -Path $outputSitePath)) {
throw "Expected Zensical output at $outputSitePath but it was not created."
}
50 changes: 50 additions & 0 deletions .github/actions/Build-ZensicalSite/src/main.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#Requires -Version 7.0

<#
.SYNOPSIS
Builds the Zensical site and normalizes output to the expected _site path.

.DESCRIPTION
Runs zensical build from outputs/site and moves the generated _site directory
to <WorkingDirectory>/_site for downstream workflow steps.

.EXAMPLE
./main.ps1 -WorkingDirectory '.'

.INPUTS
None.

.OUTPUTS
None.
#>
[CmdletBinding()]
param(
# Build working directory containing outputs/site and destination _site.
[Parameter(Mandatory)]
[string]$WorkingDirectory
)

$ErrorActionPreference = 'Stop'

$resolvedWorkingDirectory = Resolve-Path -Path $WorkingDirectory | Select-Object -ExpandProperty Path
$siteWorkingDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath 'outputs/site'
$outputSitePath = Join-Path -Path $resolvedWorkingDirectory -ChildPath '_site'

Set-Location -Path $siteWorkingDirectory

if (-not (Test-Path -Path 'zensical.toml')) {
throw "No documentation config file found in outputs/site. Expected zensical.toml."
}

zensical build --config-file 'zensical.toml'

if (Test-Path -Path '_site') {
if (Test-Path -Path $outputSitePath) {
Remove-Item -Path $outputSitePath -Recurse -Force
}
Move-Item -Path '_site' -Destination $outputSitePath -Force
}

if (-not (Test-Path -Path $outputSitePath)) {
throw "Expected Zensical output at $outputSitePath but it was not created."
}
4 changes: 1 addition & 3 deletions .github/actions/Cleanup-PSModulePrereleases/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
env:
PSMODULE_CLEANUP_PSMODULEPRERELEASES_INPUT_WhatIf: ${{ inputs.WhatIf }}
PSMODULE_CLEANUP_PSMODULEPRERELEASES_CONTEXT_ReleaseTag: ${{ env.PSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag }}
run: |
# Cleanup prerelease tags
${{ github.action_path }}/src/cleanup.ps1
run: ${{ github.action_path }}/src/cleanup.ps1

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param()

$PSStyle.OutputRendering = 'Ansi'

Import-Module -Name 'Helpers' -Force
Import-Module -Name 'PSModule' -Force

#region Load inputs
LogGroup 'Load inputs' {
Expand Down
4 changes: 1 addition & 3 deletions .github/actions/Document-PSModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@
DOCUMENT_PSMODULE_INPUT_Name: ${{ inputs.Name }}
DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }}
working-directory: ${{ inputs.WorkingDirectory }}
run: |
# Build-PSModuleDocumentation
${{ github.action_path }}/src/main.ps1
run: ${{ github.action_path }}/src/main.ps1

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
3 changes: 1 addition & 2 deletions .github/actions/Expose-TestData/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ runs:
shell: pwsh
env:
PSMODULE_TEST_DATA: ${{ inputs.TestData }}
run: |
Import-TestData
run: Import-TestData
18 changes: 18 additions & 0 deletions .github/actions/Inject-SiteScripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Inject-SiteScripts

Injects JavaScript snippets from `.github/scripts/site-injectors/*.js` into generated HTML files.

## Inputs

- `SitePath` (required): Path to generated site output.
- `WorkflowPath` (optional, default `_wf`): Path where workflow repository is checked out.

## Usage

```yaml
- name: Inject shared site scripts
uses: ./_wf/.github/actions/Inject-SiteScripts
with:
SitePath: ./_site
WorkflowPath: _wf
```
21 changes: 21 additions & 0 deletions .github/actions/Inject-SiteScripts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Inject-SiteScripts
description: Inject shared JavaScript snippets into generated site HTML files.

inputs:
SitePath:
description: Path to the generated site output directory.
required: true
WorkflowPath:
description: Path to the checked out workflow repository root.
required: false
default: _wf

runs:
using: composite
steps:
- name: Inject site scripts
shell: pwsh
env:
INPUT_SITE_PATH: ${{ inputs.SitePath }}
INPUT_WORKFLOW_PATH: ${{ inputs.WorkflowPath }}
run: '& "${{ github.action_path }}/src/main.ps1" -SitePath "$env:INPUT_SITE_PATH" -WorkflowPath "$env:INPUT_WORKFLOW_PATH"'

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
41 changes: 41 additions & 0 deletions .github/actions/Inject-SiteScripts/src/inject-site-scripts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
param(
[Parameter(Mandatory)]
[string]$SitePath,

[Parameter(Mandatory)]
[string]$WorkflowPath
)

$resolvedSitePath = Resolve-Path -Path $SitePath -ErrorAction Stop | Select-Object -ExpandProperty Path
$injectorsPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "$WorkflowPath/.github/scripts/site-injectors"

if (-not (Test-Path -Path $injectorsPath)) {
throw "Expected site injector folder at $injectorsPath but it was not found."
}

$injectorScripts = Get-ChildItem -Path $injectorsPath -File -Filter '*.js' | Sort-Object -Property Name
if (-not $injectorScripts) {
Write-Host "No site injector scripts found under $injectorsPath."
exit 0
}

Get-ChildItem -Path $resolvedSitePath -Filter '*.html' -Recurse | ForEach-Object {
$html = Get-Content -Path $_.FullName -Raw
$modified = $false

foreach ($injectorScript in $injectorScripts) {
$marker = "data-psmodule-site-injector=""$($injectorScript.Name)"""
if ($html -match [Regex]::Escape($marker)) {
continue
}

$scriptContent = Get-Content -Path $injectorScript.FullName -Raw
$injectedScript = "<script $marker>$scriptContent</script>"
$html = $html -replace '</body>', "$injectedScript`n</body>"
$modified = $true
}

if ($modified) {
Set-Content -Path $_.FullName -Value $html -NoNewline
}
}
63 changes: 63 additions & 0 deletions .github/actions/Inject-SiteScripts/src/main.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#Requires -Version 7.0

<#
.SYNOPSIS
Injects shared JavaScript snippets into generated site HTML files.

.DESCRIPTION
Reads scripts from .github/scripts/site-injectors in the checked out workflow
repository and injects each script into every HTML file under SitePath, once per file.

.EXAMPLE
./main.ps1 -SitePath './_site' -WorkflowPath '_wf'

.INPUTS
None.

.OUTPUTS
None.
#>
[CmdletBinding()]
param(
# Path to generated site output directory containing HTML files.
[Parameter(Mandatory)]
[string]$SitePath,

# Relative path to the checked out workflow repository root.
[Parameter(Mandatory)]
[string]$WorkflowPath
)

$resolvedSitePath = Resolve-Path -Path $SitePath -ErrorAction Stop | Select-Object -ExpandProperty Path
$injectorsPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "$WorkflowPath/.github/scripts/site-injectors"

if (-not (Test-Path -Path $injectorsPath)) {
throw "Expected site injector folder at $injectorsPath but it was not found."
}

$injectorScripts = Get-ChildItem -Path $injectorsPath -File -Filter '*.js' | Sort-Object -Property Name
if (-not $injectorScripts) {
Write-Host "No site injector scripts found under $injectorsPath."
exit 0
}

Get-ChildItem -Path $resolvedSitePath -Filter '*.html' -Recurse | ForEach-Object {
$html = Get-Content -Path $_.FullName -Raw
$modified = $false

foreach ($injectorScript in $injectorScripts) {
$marker = "data-psmodule-site-injector=""$($injectorScript.Name)"""
if ($html -match [Regex]::Escape($marker)) {
continue
}

$scriptContent = Get-Content -Path $injectorScript.FullName -Raw
$injectedScript = "<script $marker>$scriptContent</script>"
$html = $html -replace '</body>', "$injectedScript`n</body>"
$modified = $true
}

if ($modified) {
Set-Content -Path $_.FullName -Value $html -NoNewline
}
}
4 changes: 1 addition & 3 deletions .github/actions/Install-PSModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
steps:
- name: Install-PSModule
shell: pwsh
run: |
# Install-PSModule
${{ github.action_path }}/src/main.ps1
run: ${{ github.action_path }}/src/main.ps1

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
14 changes: 14 additions & 0 deletions .github/actions/Install-Zensical/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Install-Zensical

Installs the Zensical CLI used by site build workflows.

## Inputs

None.

## Usage

```yaml
- name: Install Zensical
uses: ./_wf/.github/actions/Install-Zensical
```
9 changes: 9 additions & 0 deletions .github/actions/Install-Zensical/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Install-Zensical
description: Install Zensical CLI used for documentation site generation.

runs:
using: composite
steps:
- name: Install Zensical CLI
shell: pwsh
run: '& "${{ github.action_path }}/src/main.ps1"'

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
3 changes: 3 additions & 0 deletions .github/actions/Install-Zensical/src/install-zensical.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ErrorActionPreference = 'Stop'

pip install zensical
24 changes: 24 additions & 0 deletions .github/actions/Install-Zensical/src/main.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#Requires -Version 7.0

<#
.SYNOPSIS
Installs the Zensical CLI used by site build workflows.

.DESCRIPTION
Installs the zensical Python package in the current runner environment.

.EXAMPLE
./main.ps1

.INPUTS
None.

.OUTPUTS
None.
#>
[CmdletBinding()]
param()

$ErrorActionPreference = 'Stop'

pip install zensical
3 changes: 1 addition & 2 deletions .github/actions/Publish-PSModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ runs:

- name: Update Microsoft.PowerShell.PSResourceGet
shell: pwsh
run: |
Install-PSResource -Name Microsoft.PowerShell.PSResourceGet -Repository PSGallery -TrustRepository
run: Install-PSResource -Name Microsoft.PowerShell.PSResourceGet -Repository PSGallery -TrustRepository

- name: Download module artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/Publish-PSModule/src/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ param()

$PSStyle.OutputRendering = 'Ansi'

Import-Module -Name 'Helpers' -Force
Import-Module -Name 'PSModule' -Force

#region Load inputs
LogGroup 'Load inputs' {
Expand Down
Loading
Loading