Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
114 changes: 58 additions & 56 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,64 +524,66 @@ jobs:
pip install mkdocs-git-revision-date-localized-plugin
pip install mkdocs-git-committers-plugin-2

- name: Run Script
shell: pwsh
run: |
$ModuleName = '${{ inputs.Name }}'

if (-not $ModuleName) {
$ModuleName = $env:GITHUB_REPOSITORY -replace '.+/'
}
Write-Verbose "Module name: $ModuleName"

$ModuleSourcePath = Join-Path (Get-Location) -ChildPath '${{ inputs.Path }}'
$DocsOutputPath = Join-Path (Get-Location) -ChildPath "${{ inputs.DocsOutputPath }}/$ModuleName"
$SiteOutputPath = Join-Path (Get-Location) -ChildPath '${{ inputs.SiteOutputPath }}'

$functionDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions'
$functionDocsFolder = New-Item -Path $functionDocsFolderPath -ItemType Directory -Force
Get-ChildItem -Path $DocsOutputPath -Recurse -Force -Include '*.md' | Copy-Item -Destination $functionDocsFolder -Recurse -Force
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$fileName = $_.Name
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
Start-LogGroup " - [$fileName] - [$hash]"
Show-FileContent -Path $_
Stop-LogGroup
}

Start-LogGroup 'Build docs - Process about topics'
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
Stop-LogGroup
- name: Structure site
uses: PSModule/GitHub-Script@v1
with:
Script: |
$ModuleName = '${{ inputs.Name }}'

Start-LogGroup 'Build docs - Copy icon to assets'
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
$null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose

Start-LogGroup 'Build docs - Copy readme.md'
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
Stop-LogGroup
if (-not $ModuleName) {
$ModuleName = $env:GITHUB_REPOSITORY -replace '.+/'
}
Write-Verbose "Module name: $ModuleName"

$ModuleSourcePath = Join-Path (Get-Location) -ChildPath '${{ inputs.Path }}'
$DocsOutputPath = Join-Path (Get-Location) -ChildPath "${{ inputs.DocsOutputPath }}/$ModuleName"
$SiteOutputPath = Join-Path (Get-Location) -ChildPath '${{ inputs.SiteOutputPath }}'

$functionDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions'
$functionDocsFolder = New-Item -Path $functionDocsFolderPath -ItemType Directory -Force
Copy-Item -Path $DocsOutputPath -Destination $functionDocsFolder -Recurse -Force
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$fileName = $_.Name
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
LogGroup " - [$fileName] - [$hash]" {
Show-FileContent -Path $_
}
}

Start-LogGroup 'Build docs - Create mkdocs.yml'
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
Show-FileContent -Path $mkdocsTargetPath
Stop-LogGroup
LogGroup 'Build docs - Process about topics' {
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
}

LogGroup 'Build docs - Copy icon to assets' {
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
$null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose
}

LogGroup 'Build docs - Copy readme.md' {
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
}

LogGroup 'Build docs - Create mkdocs.yml' {
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
Show-FileContent -Path $mkdocsTargetPath
}

- name: Debug File system
shell: pwsh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#Requires -Modules Utilities
#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' }
#Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' }
#Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' }

function Get-PSModuleTest {
<#
Expand Down
1 change: 1 addition & 0 deletions tests/src/functions/public/PSModule/PSModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is PSModule
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is SomethingElse
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#Requires -Modules Utilities
#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' }
#Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' }
#Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' }

function Get-PSModuleTest {
<#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is PSModule
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is SomethingElse