1- name : Build-PSModuleDocumentation (by PSModule)
1+ name : Document-PSModule (by PSModule)
22description : Build documentation for a PowerShell module.
33author : PSModule
44branding :
5454 name : ${{ inputs.ModuleArtifactName }}
5555 path : ${{ inputs.ModulesOutputPath }}
5656
57- - name : Run Build-PSModuleDocumentation
57+ - name : Document-PSModule
5858 uses : PSModule/GitHub-Script@v1
5959 env :
6060 GITHUB_ACTION_INPUT_Name : ${{ inputs.Name }}
@@ -77,3 +77,126 @@ runs:
7777 path : ${{ inputs.DocsOutputPath }}
7878 if-no-files-found : error
7979 retention-days : 1
80+
81+ - name : Commit all changes
82+ continue-on-error : true
83+ shell : pwsh
84+ run : |
85+ # Rename the gitignore file to .gitignore.bak
86+ Rename-Item -Path '.gitignore' -NewName '.gitignore.bak' -Force
87+
88+ try {
89+ # Add all changes to the repository
90+ git add .
91+ git commit -m 'Update documentation'
92+ } catch {
93+ Write-Host "No changes to commit"
94+ }
95+
96+ # Restore the gitignore file
97+ Rename-Item -Path '.gitignore.bak' -NewName '.gitignore' -Force
98+
99+ - name : Lint documentation
100+ uses : super-linter/super-linter/slim@latest
101+ env :
102+ FILTER_REGEX_INCLUDE : ${{ inputs.DocsOutputPath }}
103+ DEFAULT_BRANCH : main
104+ DEFAULT_WORKSPACE : ${{ github.workspace }}
105+ ENABLE_GITHUB_ACTIONS_GROUP_TITLE : true
106+ GITHUB_TOKEN : ${{ github.token }}
107+ RUN_LOCAL : true
108+ VALIDATE_ALL_CODEBASE : true
109+ VALIDATE_JSON_PRETTIER : false
110+ VALIDATE_MARKDOWN_PRETTIER : false
111+ VALIDATE_YAML_PRETTIER : false
112+ VALIDATE_GITLEAKS : false
113+
114+ - uses : actions/configure-pages@v5
115+
116+ - name : Install mkdoks-material
117+ shell : pwsh
118+ run : |
119+ pip install mkdocs-material
120+ pip install mkdocs-git-authors-plugin
121+ pip install mkdocs-git-revision-date-localized-plugin
122+ pip install mkdocs-git-committers-plugin-2
123+
124+ - name : Structure site
125+ uses : PSModule/GitHub-Script@v1
126+ with :
127+ Debug : ${{ inputs.Debug }}
128+ Prerelease : ${{ inputs.Prerelease }}
129+ Verbose : ${{ inputs.Verbose }}
130+ Version : ${{ inputs.Version }}
131+ Script : |
132+ New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force
133+ Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}/*" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force
134+ $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
135+ $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}'
136+ $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}'
137+
138+ LogGroup "Get folder structure" {
139+ Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List
140+ }
141+
142+ $functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item
143+ Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
144+ $fileName = $_.Name
145+ LogGroup " - $fileName" {
146+ Show-FileContent -Path $_
147+ }
148+ }
149+
150+ LogGroup 'Build docs - Process about topics' {
151+ $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
152+ $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
153+ $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
154+ Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
155+ Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
156+ }
157+
158+ LogGroup 'Build docs - Copy icon to assets' {
159+ $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
160+ $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
161+ $rootPath = Split-Path -Path $ModuleSourcePath -Parent
162+ $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
163+ Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose
164+ }
165+
166+ LogGroup 'Build docs - Copy readme.md' {
167+ $rootPath = Split-Path -Path $ModuleSourcePath -Parent
168+ $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
169+ $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
170+ Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
171+ }
172+
173+ LogGroup 'Build docs - Create mkdocs.yml' {
174+ $rootPath = Split-Path -Path $ModuleSourcePath -Parent
175+ # This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
176+ $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
177+ $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
178+ $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
179+ $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
180+ $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
181+ $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
182+ Show-FileContent -Path $mkdocsTargetPath
183+ }
184+
185+ - name : Debug File system
186+ shell : pwsh
187+ run : |
188+ Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object
189+
190+ - name : Build mkdocs-material project
191+ working-directory : ${{ inputs.SiteOutputPath }}
192+ shell : pwsh
193+ run : |
194+ LogGroup 'Build docs - mkdocs build - content' {
195+ Show-FileContent -Path mkdocs.yml
196+ }
197+
198+ LogGroup 'Build docs - mkdocs build' {
199+ mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site
200+ }
201+
202+ - uses : actions/upload-pages-artifact@v3
0 commit comments