Skip to content

Commit 9388dde

Browse files
Align new actions with MSX standards
Apply MSXOrg/docs standards to newly introduced internal actions: use consistent src/main.ps1 entry points, add PowerShell script headers/cmdlet binding, and add action README documentation for discoverability and reuse. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 5e8c7ff commit 9388dde

12 files changed

Lines changed: 234 additions & 4 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Build-ZensicalSite
2+
3+
Builds Zensical documentation site output and normalizes it to `<working-directory>/_site`.
4+
5+
## Inputs
6+
7+
- `WorkingDirectory` (required): Build working directory.
8+
9+
## Usage
10+
11+
```yaml
12+
- name: Build documentation site with Zensical
13+
uses: ./_wf/.github/actions/Build-ZensicalSite
14+
with:
15+
WorkingDirectory: .
16+
```

.github/actions/Build-ZensicalSite/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ runs:
1111
steps:
1212
- name: Build documentation site
1313
shell: pwsh
14-
run: '& "${{ github.action_path }}/src/build-zensical-site.ps1" -WorkingDirectory "${{ inputs.WorkingDirectory }}"'
14+
run: '& "${{ github.action_path }}/src/main.ps1" -WorkingDirectory "${{ inputs.WorkingDirectory }}"'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#Requires -Version 7.0
2+
3+
[CmdletBinding()]
4+
param(
5+
[Parameter(Mandatory)]
6+
[string]$WorkingDirectory
7+
)
8+
9+
$ErrorActionPreference = 'Stop'
10+
11+
$resolvedWorkingDirectory = Resolve-Path -Path $WorkingDirectory | Select-Object -ExpandProperty Path
12+
$siteWorkingDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath 'outputs/site'
13+
$outputSitePath = Join-Path -Path $resolvedWorkingDirectory -ChildPath '_site'
14+
15+
Set-Location -Path $siteWorkingDirectory
16+
17+
if (-not (Test-Path -Path 'zensical.toml')) {
18+
throw "No documentation config file found in outputs/site. Expected zensical.toml."
19+
}
20+
21+
zensical build --config-file 'zensical.toml'
22+
23+
if (Test-Path -Path '_site') {
24+
if (Test-Path -Path $outputSitePath) {
25+
Remove-Item -Path $outputSitePath -Recurse -Force
26+
}
27+
Move-Item -Path '_site' -Destination $outputSitePath -Force
28+
}
29+
30+
if (-not (Test-Path -Path $outputSitePath)) {
31+
throw "Expected Zensical output at $outputSitePath but it was not created."
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Inject-SiteScripts
2+
3+
Injects JavaScript snippets from `.github/scripts/site-injectors/*.js` into generated HTML files.
4+
5+
## Inputs
6+
7+
- `SitePath` (required): Path to generated site output.
8+
- `WorkflowPath` (optional, default `_wf`): Path where workflow repository is checked out.
9+
10+
## Usage
11+
12+
```yaml
13+
- name: Inject shared site scripts
14+
uses: ./_wf/.github/actions/Inject-SiteScripts
15+
with:
16+
SitePath: ./_site
17+
WorkflowPath: _wf
18+
```

.github/actions/Inject-SiteScripts/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ runs:
1515
steps:
1616
- name: Inject site scripts
1717
shell: pwsh
18-
run: '& "${{ github.action_path }}/src/inject-site-scripts.ps1" -SitePath "${{ inputs.SitePath }}" -WorkflowPath "${{ inputs.WorkflowPath }}"'
18+
run: '& "${{ github.action_path }}/src/main.ps1" -SitePath "${{ inputs.SitePath }}" -WorkflowPath "${{ inputs.WorkflowPath }}"'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Requires -Version 7.0
2+
3+
[CmdletBinding()]
4+
param(
5+
[Parameter(Mandatory)]
6+
[string]$SitePath,
7+
8+
[Parameter(Mandatory)]
9+
[string]$WorkflowPath
10+
)
11+
12+
$resolvedSitePath = Resolve-Path -Path $SitePath -ErrorAction Stop | Select-Object -ExpandProperty Path
13+
$injectorsPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "$WorkflowPath/.github/scripts/site-injectors"
14+
15+
if (-not (Test-Path -Path $injectorsPath)) {
16+
throw "Expected site injector folder at $injectorsPath but it was not found."
17+
}
18+
19+
$injectorScripts = Get-ChildItem -Path $injectorsPath -File -Filter '*.js' | Sort-Object -Property Name
20+
if (-not $injectorScripts) {
21+
Write-Host "No site injector scripts found under $injectorsPath."
22+
exit 0
23+
}
24+
25+
Get-ChildItem -Path $resolvedSitePath -Filter '*.html' -Recurse | ForEach-Object {
26+
$html = Get-Content -Path $_.FullName -Raw
27+
$modified = $false
28+
29+
foreach ($injectorScript in $injectorScripts) {
30+
$marker = "data-psmodule-site-injector=""$($injectorScript.Name)"""
31+
if ($html -match [Regex]::Escape($marker)) {
32+
continue
33+
}
34+
35+
$scriptContent = Get-Content -Path $injectorScript.FullName -Raw
36+
$injectedScript = "<script $marker>$scriptContent</script>"
37+
$html = $html -replace '</body>', "$injectedScript`n</body>"
38+
$modified = $true
39+
}
40+
41+
if ($modified) {
42+
Set-Content -Path $_.FullName -Value $html -NoNewline
43+
}
44+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Install-Zensical
2+
3+
Installs the Zensical CLI used by site build workflows.
4+
5+
## Inputs
6+
7+
None.
8+
9+
## Usage
10+
11+
```yaml
12+
- name: Install Zensical
13+
uses: ./_wf/.github/actions/Install-Zensical
14+
```

.github/actions/Install-Zensical/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ runs:
66
steps:
77
- name: Install Zensical CLI
88
shell: pwsh
9-
run: '& "${{ github.action_path }}/src/install-zensical.ps1"'
9+
run: '& "${{ github.action_path }}/src/main.ps1"'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Requires -Version 7.0
2+
3+
[CmdletBinding()]
4+
param()
5+
6+
$ErrorActionPreference = 'Stop'
7+
8+
pip install zensical
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Structure-Site
2+
3+
Prepares site content and writes a resolved Zensical config file under `outputs/site`.
4+
5+
## Inputs
6+
7+
- `WorkingDirectory` (required): Build working directory.
8+
- `Name` (optional): Module name override.
9+
10+
## Usage
11+
12+
```yaml
13+
- name: Structure site
14+
uses: ./_wf/.github/actions/Structure-Site
15+
with:
16+
WorkingDirectory: .
17+
Name: MyModule
18+
```

0 commit comments

Comments
 (0)