Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
35 changes: 32 additions & 3 deletions .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ permissions:
statuses: write # to create commit status

jobs:
ActionTestDefault:
name: Action-Test - [Default]
UploadArtifact:
name: Upload Artifact
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -41,12 +41,22 @@ jobs:
if-no-files-found: error
retention-days: 1

ActionTestDefault:
name: Action-Test - [Default]
runs-on: ubuntu-latest
needs: UploadArtifact
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
persist-credentials: false
fetch-depth: 0

- name: Action-Test
uses: ./
with:
Name: PSModuleTest
WorkingDirectory: tests/srcTestRepo
ShowSummaryOnSuccess: true

- name: Lint documentation
uses: super-linter/super-linter/slim@v8.1.0
Expand All @@ -56,3 +66,22 @@ jobs:
VALIDATE_NATURAL_LANGUAGE: true
VALIDATE_ALL_CODEBASE: true
USE_FIND_ALGORITHM: true

ActionTestWithSummary:
name: Action-Test - [With Summary]
runs-on: ubuntu-latest
needs: UploadArtifact
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
persist-credentials: false
fetch-depth: 0


- name: Action-Test
uses: ./
with:
Name: PSModuleTest
WorkingDirectory: tests/srcTestRepo
ShowSummaryOnSuccess: true
12 changes: 6 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ inputs:
Name:
description: Name of the module to process.
required: false
WorkingDirectory:
description: The working directory where the script will run from.
required: false
default: '.'
ShowSummaryOnSuccess:
description: Show GitHub Step Summary even when all commands succeed.
required: false
default: 'false'
WorkingDirectory:
description: The working directory where the script will run from.
required: false
default: '.'

runs:
using: composite
Expand All @@ -27,8 +27,8 @@ runs:
- name: Document-PSModule
shell: pwsh
env:
GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }}
GITHUB_ACTION_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }}
DOCUMENT_PSMODULE_INPUT_Name: ${{ inputs.Name }}
DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }}
working-directory: ${{ inputs.WorkingDirectory }}
run: |
# Build-PSModuleDocumentation
Expand Down
46 changes: 36 additions & 10 deletions scripts/helpers/Build-PSModuleDocumentation.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function Build-PSModuleDocumentation {
<#
.SYNOPSIS
Builds a module.
.SYNOPSIS
Builds a module.

.DESCRIPTION
Builds a module.
.DESCRIPTION
Builds a module.
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
Expand Down Expand Up @@ -93,9 +93,9 @@
$failedCommands = $commandResults | Where-Object { $_.Status -eq 'Failed' }
$successfulCommands = $commandResults | Where-Object { $_.Status -eq 'Success' }
$hasFailures = $failedCommands.Count -gt 0
$shouldShowSummary = $hasFailures -or $ShowSummaryOnSuccess
$shouldShowSummary = $ShowSummaryOnSuccess

# Generate summary if there are failures OR if ShowSummaryOnSuccess is enabled
# Generate summary if ShowSummaryOnSuccess is enabled
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
if ($shouldShowSummary) {
$statusIcon = $hasFailures ? '❌' : '✅'
$statusText = $hasFailures ? 'Failed' : 'Succeeded'
Expand All @@ -111,13 +111,39 @@
|---------|---------|
| $successCount | $failureCount |

## Command status
"@

if ($failedCommands) {
$summaryContent += @"

<details><summary>Failed</summary>

<p>

$(($failedCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '')
Comment thread
MariusStorhaug marked this conversation as resolved.

</p>

</details>

"@
}

if ($successfulCommands) {
$summaryContent += @"

<details><summary>Succeeded</summary>

| Command | Status |
|---------|--------|
$(($commandResults | ForEach-Object { "| ``$($_.CommandName)`` | $($_.Status) |`n" }) -join '')
<p>

$(($successfulCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '')
Comment thread
MariusStorhaug marked this conversation as resolved.

</p>

</details>

"@
}


$summaryContent | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
Expand Down
11 changes: 6 additions & 5 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
Justification = 'Want to just write to the console, not the pipeline.'
)]
[CmdletBinding()]
param()
param(
[string]$Name = $env:DOCUMENT_PSMODULE_INPUT_Name,
[bool]$ShowSummaryOnSuccess = $env:DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess -eq 'true'
Comment thread
MariusStorhaug marked this conversation as resolved.
)

$PSStyle.OutputRendering = 'Ansi'

Expand Down Expand Up @@ -37,18 +40,16 @@ Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | Fo

Write-Host '::group::Loading inputs'
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'
$moduleName = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Name) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name
$showSummaryOnSuccess = $env:GITHUB_ACTION_INPUT_ShowSummaryOnSuccess -eq 'true'
$moduleSourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path
$modulesOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/module'
$docsOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/docs'

$params = @{
ModuleName = $moduleName
ModuleName = [string]::IsNullOrEmpty($Name) ? $env:GITHUB_REPOSITORY_NAME : $Name
ModuleSourceFolderPath = $moduleSourceFolderPath
ModulesOutputFolderPath = $modulesOutputFolderPath
DocsOutputFolderPath = $docsOutputFolderPath
ShowSummaryOnSuccess = $showSummaryOnSuccess
ShowSummaryOnSuccess = $ShowSummaryOnSuccess
}

[pscustomobject]$params | Format-List | Out-String
Expand Down
Loading