Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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: .
```
14 changes: 14 additions & 0 deletions .github/actions/Build-ZensicalSite/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
run: '& "${{ github.action_path }}/src/main.ps1" -WorkingDirectory "${{ inputs.WorkingDirectory }}"'

Check warning

Code scanning / CodeQL

Code injection Medium

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

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ inputs.WorkingDirectory }
, which may be controlled by an external user.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
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."
}
32 changes: 32 additions & 0 deletions .github/actions/Build-ZensicalSite/src/main.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#Requires -Version 7.0

[CmdletBinding()]
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."
}
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
```
18 changes: 18 additions & 0 deletions .github/actions/Inject-SiteScripts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
run: '& "${{ github.action_path }}/src/main.ps1" -SitePath "${{ inputs.SitePath }}" -WorkflowPath "${{ inputs.WorkflowPath }}"'

Check warning

Code scanning / CodeQL

Code injection Medium

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

Check warning

Code scanning / CodeQL

Code injection Medium

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

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ inputs.WorkflowPath }
, which may be controlled by an external user.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
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
}
}
44 changes: 44 additions & 0 deletions .github/actions/Inject-SiteScripts/src/main.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#Requires -Version 7.0

[CmdletBinding()]
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
}
}
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
8 changes: 8 additions & 0 deletions .github/actions/Install-Zensical/src/main.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Requires -Version 7.0

[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
7 changes: 2 additions & 5 deletions .github/actions/Resolve-PSModuleVersion/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@

- name: Install PSSemVer
shell: pwsh
run: |
Install-PSResource -Name PSSemVer -Repository PSGallery -TrustRepository
run: Install-PSResource -Name PSSemVer -Repository PSGallery -TrustRepository

- name: Resolve module version
id: resolve
Expand All @@ -71,6 +70,4 @@
PSMODULE_RESOLVE_PSMODULEVERSION_INPUT_Name: ${{ inputs.Name }}
PSMODULE_RESOLVE_PSMODULEVERSION_INPUT_EventJson: ${{ inputs.EventJson }}
GITHUB_EVENT_PATH: ${{ inputs.EventPath || github.event_path }}
run: |
# Resolve module version
${{ 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.
18 changes: 18 additions & 0 deletions .github/actions/Structure-Site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Structure-Site

Prepares site content and writes a resolved Zensical config file under `outputs/site`.

## Inputs

- `WorkingDirectory` (required): Build working directory.
- `Name` (optional): Module name override.

## Usage

```yaml
- name: Structure site
uses: ./_wf/.github/actions/Structure-Site
with:
WorkingDirectory: .
Name: MyModule
```
18 changes: 18 additions & 0 deletions .github/actions/Structure-Site/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Structure-Site
description: Structure generated docs and create site config for Zensical.

inputs:
WorkingDirectory:
description: Working directory for the repository build.
required: true
Name:
description: Optional module name override.
required: false
default: ''

runs:
using: composite
steps:
- name: Structure site content and config
shell: pwsh
run: '& "${{ github.action_path }}/src/main.ps1" -WorkingDirectory "${{ inputs.WorkingDirectory }}" -Name "${{ inputs.Name }}"'

Check warning

Code scanning / CodeQL

Code injection Medium

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

Check warning

Code scanning / CodeQL

Code injection Medium

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

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ inputs.Name }
, which may be controlled by an external user.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Loading
Loading