Skip to content

Commit ca0d1db

Browse files
2 parents aef4152 + 9810ff9 commit ca0d1db

File tree

10 files changed

+462
-256
lines changed

10 files changed

+462
-256
lines changed

.github/workflows/Build-Docs.yml

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ jobs:
5656
uses: PSModule/Document-PSModule@v1
5757
with:
5858
Name: ${{ inputs.Name }}
59-
Debug: ${{ inputs.Debug }}
60-
Prerelease: ${{ inputs.Prerelease }}
61-
Verbose: ${{ inputs.Verbose }}
62-
Version: ${{ inputs.Version }}
6359
WorkingDirectory: ${{ inputs.WorkingDirectory }}
6460

6561
- name: Upload docs artifact
@@ -112,136 +108,3 @@ jobs:
112108
VALIDATE_YAML_PRETTIER: false
113109
VALIDATE_JSCPD: false
114110
VALIDATE_GITLEAKS: false
115-
116-
- uses: actions/configure-pages@v5
117-
118-
- name: Install mkdoks-material
119-
shell: pwsh
120-
run: |
121-
pip install mkdocs-material
122-
pip install mkdocs-git-authors-plugin
123-
pip install mkdocs-git-revision-date-localized-plugin
124-
pip install mkdocs-git-committers-plugin-2
125-
126-
- name: Structure site
127-
uses: PSModule/GitHub-Script@v1
128-
with:
129-
Debug: ${{ inputs.Debug }}
130-
Prerelease: ${{ inputs.Prerelease }}
131-
Verbose: ${{ inputs.Verbose }}
132-
Version: ${{ inputs.Version }}
133-
WorkingDirectory: ${{ inputs.WorkingDirectory }}
134-
Script: |
135-
LogGroup "Get folder structure" {
136-
$functionDocsFolder = New-Item -Path "outputs/site/docs/Functions" -ItemType Directory -Force
137-
Copy-Item -Path "outputs/docs/*" -Destination "outputs/site/docs/Functions" -Recurse -Force
138-
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
139-
$ModuleSourcePath = Resolve-Path 'src' | Select-Object -ExpandProperty Path
140-
$SiteOutputPath = Resolve-Path 'outputs/site' | Select-Object -ExpandProperty Path
141-
142-
Write-Host "Function Docs Folder: $functionDocsFolder"
143-
Write-Host "Module Name: $moduleName"
144-
Write-Host "Module Source Path: $ModuleSourcePath"
145-
Write-Host "Site Output Path: $SiteOutputPath"
146-
}
147-
148-
LogGroup "Get folder structure" {
149-
Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List
150-
}
151-
152-
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
153-
$fileName = $_.Name
154-
LogGroup " - $fileName" {
155-
Show-FileContent -Path $_
156-
}
157-
}
158-
159-
LogGroup 'Build docs - Process about topics' {
160-
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
161-
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
162-
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
163-
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
164-
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
165-
166-
Write-Host "About Docs Folder: $aboutDocsFolder"
167-
Write-Host "About Source Folder: $aboutSourceFolder"
168-
}
169-
170-
LogGroup 'Build docs - Copy icon to assets' {
171-
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
172-
$assetsFolder = New-Item -Path $assetsFolderPath -ItemType Directory -Force
173-
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
174-
$iconPath = Resolve-Path 'icon\icon.png' | Select-Object -ExpandProperty Path
175-
Copy-Item -Path $iconPath -Destination $assetsFolder -Force -Verbose
176-
177-
Write-Host "Assets Folder: $assetsFolder"
178-
Write-Host "Icon Path: $iconPath"
179-
}
180-
181-
LogGroup 'Build docs - Copy readme.md' {
182-
$readmePath = Resolve-Path 'README.md' | Select-Object -ExpandProperty Path
183-
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
184-
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
185-
186-
Write-Host "Readme Path: $readmePath"
187-
Write-Host "Readme Target Path: $readmeTargetPath"
188-
}
189-
190-
LogGroup 'Build docs - Create mkdocs.yml' {
191-
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
192-
$possiblePaths = @(
193-
'.github/mkdocs.yml',
194-
'docs/mkdocs.yml',
195-
'mkdocs.yml'
196-
)
197-
198-
$mkdocsSourcePath = $null
199-
foreach ($path in $possiblePaths) {
200-
$candidatePath = Join-Path -Path $rootPath -ChildPath $path
201-
if (Test-Path -Path $candidatePath) {
202-
$mkdocsSourcePath = $candidatePath
203-
break
204-
}
205-
}
206-
207-
if (-not $mkdocsSourcePath) {
208-
throw "Mkdocs source file not found in any of the expected locations: $($possiblePaths -join ', ')"
209-
}
210-
211-
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
212-
213-
Write-Host "Mkdocs Source Path: $mkdocsSourcePath"
214-
Write-Host "Mkdocs Target Path: $mkdocsTargetPath"
215-
216-
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
217-
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
218-
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
219-
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
220-
Show-FileContent -Path $mkdocsTargetPath
221-
}
222-
223-
- name: Debug File system
224-
shell: pwsh
225-
working-directory: ${{ inputs.WorkingDirectory }}
226-
run: |
227-
Get-ChildItem -Path . -Recurse | ForEach-Object {
228-
[System.IO.Path]::GetRelativePath($PSScriptRoot, $_.FullName)
229-
} | Sort-Object
230-
231-
- name: Build mkdocs-material project
232-
working-directory: ${{ inputs.WorkingDirectory }}/outputs/site
233-
shell: pwsh
234-
run: |
235-
LogGroup 'Build docs - mkdocs build - content' {
236-
Show-FileContent -Path mkdocs.yml
237-
}
238-
239-
LogGroup 'Build docs - mkdocs build' {
240-
mkdocs build --config-file mkdocs.yml --site-dir ../../_site
241-
}
242-
243-
- uses: actions/upload-pages-artifact@v3
244-
with:
245-
name: github-pages
246-
path: ${{ inputs.WorkingDirectory }}/_site
247-
retention-days: 1

.github/workflows/Build-Site.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Build-Site
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
Name:
7+
type: string
8+
description: The name of the module to process. Scripts default to the repository name if nothing is specified.
9+
required: false
10+
Debug:
11+
type: boolean
12+
description: Enable debug output.
13+
required: false
14+
default: false
15+
Verbose:
16+
type: boolean
17+
description: Enable verbose output.
18+
required: false
19+
default: false
20+
Version:
21+
type: string
22+
description: Specifies the version of the GitHub module to be installed. The value must be an exact version.
23+
required: false
24+
default: ''
25+
Prerelease:
26+
type: boolean
27+
description: Whether to use a prerelease version of the 'GitHub' module.
28+
required: false
29+
default: false
30+
WorkingDirectory:
31+
type: string
32+
description: The working directory where the script will run from.
33+
required: false
34+
default: '.'
35+
36+
permissions:
37+
contents: read # to checkout the repo
38+
39+
jobs:
40+
Build-Site:
41+
name: Build-Site
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout Code
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
49+
- name: Install-PSModuleHelpers
50+
uses: PSModule/Install-PSModuleHelpers@v1
51+
52+
- name: Download docs artifact
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: docs
56+
path: ${{ inputs.WorkingDirectory }}/outputs/docs
57+
58+
- name: Install mkdocs-material
59+
shell: pwsh
60+
run: |
61+
pip install mkdocs-material
62+
pip install mkdocs-git-authors-plugin
63+
pip install mkdocs-git-revision-date-localized-plugin
64+
pip install mkdocs-git-committers-plugin-2
65+
66+
- name: Structure site
67+
uses: PSModule/GitHub-Script@v1
68+
with:
69+
Debug: ${{ inputs.Debug }}
70+
Prerelease: ${{ inputs.Prerelease }}
71+
Verbose: ${{ inputs.Verbose }}
72+
Version: ${{ inputs.Version }}
73+
WorkingDirectory: ${{ inputs.WorkingDirectory }}
74+
Script: |
75+
LogGroup "Get folder structure" {
76+
$functionDocsFolder = New-Item -Path "outputs/site/docs/Functions" -ItemType Directory -Force
77+
Copy-Item -Path "outputs/docs/*" -Destination "outputs/site/docs/Functions" -Recurse -Force
78+
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
79+
$ModuleSourcePath = Resolve-Path 'src' | Select-Object -ExpandProperty Path
80+
$SiteOutputPath = Resolve-Path 'outputs/site' | Select-Object -ExpandProperty Path
81+
82+
Write-Host "Function Docs Folder: $functionDocsFolder"
83+
Write-Host "Module Name: $moduleName"
84+
Write-Host "Module Source Path: $ModuleSourcePath"
85+
Write-Host "Site Output Path: $SiteOutputPath"
86+
}
87+
88+
LogGroup "Get folder structure" {
89+
Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List
90+
}
91+
92+
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
93+
$fileName = $_.Name
94+
LogGroup " - $fileName" {
95+
Show-FileContent -Path $_
96+
}
97+
}
98+
99+
LogGroup 'Build docs - Process about topics' {
100+
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
101+
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
102+
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
103+
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
104+
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
105+
106+
Write-Host "About Docs Folder: $aboutDocsFolder"
107+
Write-Host "About Source Folder: $aboutSourceFolder"
108+
}
109+
110+
LogGroup 'Build docs - Copy icon to assets' {
111+
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
112+
$assetsFolder = New-Item -Path $assetsFolderPath -ItemType Directory -Force
113+
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
114+
$iconPath = Resolve-Path 'icon\icon.png' | Select-Object -ExpandProperty Path
115+
Copy-Item -Path $iconPath -Destination $assetsFolder -Force -Verbose
116+
117+
Write-Host "Assets Folder: $assetsFolder"
118+
Write-Host "Icon Path: $iconPath"
119+
}
120+
121+
LogGroup 'Build docs - Copy readme.md' {
122+
$readmePath = Resolve-Path 'README.md' | Select-Object -ExpandProperty Path
123+
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
124+
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
125+
126+
Write-Host "Readme Path: $readmePath"
127+
Write-Host "Readme Target Path: $readmeTargetPath"
128+
}
129+
130+
LogGroup 'Build docs - Create mkdocs.yml' {
131+
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
132+
$possiblePaths = @(
133+
'.github/mkdocs.yml',
134+
'docs/mkdocs.yml',
135+
'mkdocs.yml'
136+
)
137+
138+
$mkdocsSourcePath = $null
139+
foreach ($path in $possiblePaths) {
140+
$candidatePath = Join-Path -Path $rootPath -ChildPath $path
141+
if (Test-Path -Path $candidatePath) {
142+
$mkdocsSourcePath = $candidatePath
143+
break
144+
}
145+
}
146+
147+
if (-not $mkdocsSourcePath) {
148+
throw "Mkdocs source file not found in any of the expected locations: $($possiblePaths -join ', ')"
149+
}
150+
151+
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
152+
153+
Write-Host "Mkdocs Source Path: $mkdocsSourcePath"
154+
Write-Host "Mkdocs Target Path: $mkdocsTargetPath"
155+
156+
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
157+
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
158+
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
159+
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
160+
Show-FileContent -Path $mkdocsTargetPath
161+
}
162+
163+
- name: Build mkdocs-material project
164+
working-directory: ${{ inputs.WorkingDirectory }}/outputs/site
165+
shell: pwsh
166+
run: |
167+
LogGroup 'Build docs - mkdocs build - content' {
168+
Show-FileContent -Path mkdocs.yml
169+
}
170+
171+
LogGroup 'Build docs - mkdocs build' {
172+
mkdocs build --config-file mkdocs.yml --site-dir ../../_site
173+
}
174+
175+
- uses: actions/upload-pages-artifact@v3
176+
with:
177+
name: github-pages
178+
path: ${{ inputs.WorkingDirectory }}/_site
179+
retention-days: 1

0 commit comments

Comments
 (0)