From 44ceccb6176843860baf0cbea80e6bacf557ad47 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 14 Feb 2025 10:16:18 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Fix=20placement=20of=20?= =?UTF-8?q?docs=20after=20copy=20(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request includes improvements to the `CI.yml` and `workflow.yml` reusable workflows. * Modified the `Copy-Item` command to include all files in the source directory by appending `/*` to the path. * Added a `try-catch` block around the `git add` and `git commit` commands to handle cases where there are no changes to commit, preventing errors. ## Type of change - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas --- .github/workflows/CI.yml | 11 ++++++++--- .github/workflows/workflow.yml | 18 +++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c881f7da..db8e7728 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -266,8 +266,13 @@ jobs: # Rename the gitignore file to .gitignore.bak Rename-Item -Path '.gitignore' -NewName '.gitignore.bak' -Force - git add . - git commit -m 'Update documentation' + try { + # Add all changes to the repository + git add . + git commit -m 'Update documentation' + } catch { + Write-Host "No changes to commit" + } # Restore the gitignore file Rename-Item -Path '.gitignore.bak' -NewName '.gitignore' -Force @@ -307,7 +312,7 @@ jobs: Version: ${{ inputs.Version }} Script: | New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force - Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force + Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}/*" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}' $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}' $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}' diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 24be9dff..3cbf404f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -273,8 +273,13 @@ jobs: # Rename the gitignore file to .gitignore.bak Rename-Item -Path '.gitignore' -NewName '.gitignore.bak' -Force - git add . - git commit -m 'Update documentation' + try { + # Add all changes to the repository + git add . + git commit -m 'Update documentation' + } catch { + Write-Host "No changes to commit" + } # Restore the gitignore file Rename-Item -Path '.gitignore.bak' -NewName '.gitignore' -Force @@ -314,20 +319,19 @@ jobs: Version: ${{ inputs.Version }} Script: | New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force - Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force + Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}/*" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}' $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}' $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}' - LogGroup "Get folderstructure" { - Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object + LogGroup "Get folder structure" { + Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List } $functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { $fileName = $_.Name - $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash - LogGroup " - [$fileName] - [$hash]" { + LogGroup " - $fileName" { Show-FileContent -Path $_ } }