Skip to content

Commit 18fe88d

Browse files
Align scripts with MSX PowerShell guidance
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent bfd59cf commit 18fe88d

8 files changed

Lines changed: 121 additions & 24 deletions

File tree

.github/actions/update-index/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ runs:
1616
ClientID: ${{ inputs.ClientID }}
1717
PrivateKey: ${{ inputs.PrivateKey }}
1818
Script: |
19-
${{ github.action_path }}/src/main.ps1
19+
${{ github.action_path }}/src/Invoke-UpdateIndex.ps1
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#Requires -Version 7.0
2+
3+
<#
4+
.SYNOPSIS
5+
Updates generated index content for the docs repository.
6+
7+
.DESCRIPTION
8+
Orchestrates the update-index action flow by collecting organization repository
9+
metadata and regenerating module catalog documentation artifacts.
10+
11+
.EXAMPLE
12+
./Invoke-UpdateIndex.ps1
13+
#>
14+
[CmdletBinding()]
15+
param()
16+
17+
Set-StrictMode -Version Latest
18+
$ErrorActionPreference = 'Stop'
19+
20+
Import-Module -Name (Join-Path $PSScriptRoot 'update-index.Helpers.psm1')
21+
22+
LogGroup 'Initialize update-index run' {
23+
Write-Host "Starting update-index in [$PSScriptRoot]"
24+
}
25+
26+
LogGroup 'Collect repositories' {
27+
$repos = Show-RepoList
28+
Write-Host "Repository collection complete: $($repos.Count) records"
29+
}
30+
31+
LogGroup 'Skipped generators' {
32+
Write-Host 'Update-ActionList is currently disabled in Invoke-UpdateIndex.ps1'
33+
Write-Host 'Update-FunctionAppList is currently disabled in Invoke-UpdateIndex.ps1'
34+
}
35+
36+
LogGroup 'Update module catalog docs' {
37+
Update-ModuleList -Repos $repos
38+
}
39+
40+
LogGroup 'Finalize update-index run' {
41+
Write-Host 'update-index run completed'
42+
}

.github/actions/update-index/src/main.ps1

Lines changed: 0 additions & 23 deletions
This file was deleted.
File renamed without changes.

.github/scripts/docs/Cleanup-PreviewDocs.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1+
#Requires -Version 7.0
2+
3+
<#
4+
.SYNOPSIS
5+
Removes pull request preview artifacts and related environment state.
6+
7+
.DESCRIPTION
8+
Deletes previews/pr-<number> from gh-pages, deactivates and removes preview
9+
deployments, deletes the preview environment, and updates the PR comment.
10+
11+
.EXAMPLE
12+
./Cleanup-PreviewDocs.ps1 -Repository "PSModule/docs" -Token $token -PullRequestNumber 42 -PreviewUrl "https://psmodule.io/docs/previews/pr-42/" -EnvironmentName "pr-preview-42"
13+
#>
14+
[CmdletBinding()]
115
param(
16+
# Repository in owner/name format.
217
[Parameter(Mandatory = $true)]
318
[string]$Repository,
19+
# GitHub App token used for authenticated git and gh operations.
420
[Parameter(Mandatory = $true)]
521
[string]$Token,
22+
# Pull request number used for preview path and comment targeting.
623
[Parameter(Mandatory = $true)]
724
[int]$PullRequestNumber,
25+
# Public preview URL for PR comments.
826
[Parameter(Mandatory = $true)]
927
[string]$PreviewUrl,
28+
# Environment name to clean up from repository environments.
1029
[Parameter(Mandatory = $true)]
1130
[string]$EnvironmentName,
31+
# Working directory used to clone gh-pages.
1232
[string]$PagesDirectory = '_pages',
33+
# Branch used as the Pages source branch.
1334
[string]$BaseBranch = 'gh-pages'
1435
)
1536

.github/scripts/docs/Publish-LiveDocs.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1+
#Requires -Version 7.0
2+
3+
<#
4+
.SYNOPSIS
5+
Publishes live docs content to the gh-pages branch.
6+
7+
.DESCRIPTION
8+
Clones gh-pages, replaces live content while keeping previews, and pushes
9+
the updated branch using the GitHub App token identity.
10+
11+
.EXAMPLE
12+
./Publish-LiveDocs.ps1 -Repository "PSModule/docs" -Token $token -BuildDirectory "$PWD/src/site" -CommitSha $env:GITHUB_SHA
13+
#>
14+
[CmdletBinding()]
115
param(
16+
# Repository in owner/name format.
217
[Parameter(Mandatory = $true)]
318
[string]$Repository,
19+
# GitHub App token used for authenticated git and gh operations.
420
[Parameter(Mandatory = $true)]
521
[string]$Token,
22+
# Full path to the built static site directory.
623
[Parameter(Mandatory = $true)]
724
[string]$BuildDirectory,
25+
# Commit SHA used in the publish commit message.
826
[Parameter(Mandatory = $true)]
927
[string]$CommitSha,
28+
# Working directory used to clone gh-pages.
1029
[string]$PagesDirectory = '_pages',
30+
# Branch used as the Pages source branch.
1131
[string]$BaseBranch = 'gh-pages'
1232
)
1333

.github/scripts/docs/Publish-PreviewDocs.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1+
#Requires -Version 7.0
2+
3+
<#
4+
.SYNOPSIS
5+
Publishes pull request preview docs content to gh-pages.
6+
7+
.DESCRIPTION
8+
Writes the PR preview build output into previews/pr-<number> on gh-pages,
9+
pushes branch updates, and ensures the preview comment is present on the PR.
10+
11+
.EXAMPLE
12+
./Publish-PreviewDocs.ps1 -Repository "PSModule/docs" -Token $token -PullRequestNumber 42 -PreviewUrl "https://psmodule.io/docs/previews/pr-42/" -BuildDirectory "$PWD/src/site"
13+
#>
14+
[CmdletBinding()]
115
param(
16+
# Repository in owner/name format.
217
[Parameter(Mandatory = $true)]
318
[string]$Repository,
19+
# GitHub App token used for authenticated git and gh operations.
420
[Parameter(Mandatory = $true)]
521
[string]$Token,
22+
# Pull request number used for preview path and comment targeting.
623
[Parameter(Mandatory = $true)]
724
[int]$PullRequestNumber,
25+
# Public preview URL for PR comments and environment metadata.
826
[Parameter(Mandatory = $true)]
927
[string]$PreviewUrl,
28+
# Full path to the built static site directory.
1029
[Parameter(Mandatory = $true)]
1130
[string]$BuildDirectory,
31+
# Working directory used to clone gh-pages.
1232
[string]$PagesDirectory = '_pages',
33+
# Branch used as the Pages source branch.
1334
[string]$BaseBranch = 'gh-pages'
1435
)
1536

.github/scripts/docs/Set-ZensicalSiteUrl.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
#Requires -Version 7.0
2+
3+
<#
4+
.SYNOPSIS
5+
Sets the site_url field in a Zensical configuration file.
6+
7+
.DESCRIPTION
8+
Replaces the existing top-level site_url assignment in the provided
9+
zensical.toml file so workflow builds use the expected canonical URL.
10+
11+
.EXAMPLE
12+
./Set-ZensicalSiteUrl.ps1 -ConfigPath "$PWD/src/zensical.toml" -SiteUrl "https://psmodule.io/docs/previews/pr-42/"
13+
#>
14+
[CmdletBinding()]
115
param(
16+
# Full path to the Zensical config file.
217
[Parameter(Mandatory = $true)]
318
[string]$ConfigPath,
19+
# Canonical URL to write to site_url.
420
[Parameter(Mandatory = $true)]
521
[string]$SiteUrl
622
)

0 commit comments

Comments
 (0)