Skip to content

Commit d82ce5b

Browse files
🩹 [Refactor]: Enhance Build-Docs workflow by improving path resolution and adding logging for better debugging and clarity
1 parent e69630a commit d82ce5b

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

‎.github/workflows/Build-Docs.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,20 @@ jobs:
134134
Prerelease: ${{ inputs.Prerelease }}
135135
Verbose: ${{ inputs.Verbose }}
136136
Version: ${{ inputs.Version }}
137+
WorkingDirectory: ${{ inputs.Path }}
137138
Script: |
138-
$functionDocsFolder = New-Item -Path "${{ inputs.Path }}/outputs/site/docs/Functions" -ItemType Directory -Force
139-
Copy-Item -Path "${{ inputs.Path }}/outputs/docs/*" -Destination "${{ inputs.Path }}/outputs/site/docs/Functions" -Recurse -Force
140-
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
141-
$ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}'
142-
$SiteOutputPath = Join-Path $PWD -ChildPath 'outputs/site'
139+
LogGroup "Get folder structure" {
140+
$functionDocsFolder = New-Item -Path "/outputs/site/docs/Functions" -ItemType Directory -Force
141+
Copy-Item -Path "/outputs/docs/*" -Destination "/outputs/site/docs/Functions" -Recurse -Force
142+
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
143+
$ModuleSourcePath = Resolve-Path 'src' | Select-Object -ExpandProperty Path
144+
$SiteOutputPath = Resolve-Path 'outputs/site' | Select-Object -ExpandProperty Path
145+
146+
Write-Host "Function Docs Folder: $functionDocsFolder"
147+
Write-Host "Module Name: $moduleName"
148+
Write-Host "Module Source Path: $ModuleSourcePath"
149+
Write-Host "Site Output Path: $SiteOutputPath"
150+
}
143151
144152
LogGroup "Get folder structure" {
145153
Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List
@@ -158,28 +166,40 @@ jobs:
158166
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
159167
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
160168
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
169+
170+
Write-Host "About Docs Folder: $aboutDocsFolder"
171+
Write-Host "About Source Folder: $aboutSourceFolder"
161172
}
162173
163174
LogGroup 'Build docs - Copy icon to assets' {
164175
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
165176
$assetsFolder = New-Item -Path $assetsFolderPath -ItemType Directory -Force
166177
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
167-
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
178+
$iconPath = Resolve-Path 'icon\icon.png' | Select-Object -ExpandProperty Path
168179
Copy-Item -Path $iconPath -Destination $assetsFolder -Force -Verbose
180+
181+
Write-Host "Assets Folder: $assetsFolder"
182+
Write-Host "Icon Path: $iconPath"
169183
}
170184
171185
LogGroup 'Build docs - Copy readme.md' {
172-
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
173-
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
186+
$readmePath = Resolve-Path 'README.md' | Select-Object -ExpandProperty Path
174187
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
175188
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
189+
190+
Write-Host "Readme Path: $readmePath"
191+
Write-Host "Readme Target Path: $readmeTargetPath"
176192
}
177193
178194
LogGroup 'Build docs - Create mkdocs.yml' {
179195
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
180196
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
181197
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
182198
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
199+
200+
Write-Host "Mkdocs Source Path: $mkdocsSourcePath"
201+
Write-Host "Mkdocs Target Path: $mkdocsTargetPath"
202+
183203
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
184204
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
185205
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)

0 commit comments

Comments
 (0)