From e22ccce8620eed4d58bc215d8ac46d0cf78ad7c2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 27 Mar 2026 23:46:27 +0100 Subject: [PATCH 1/8] Add configurable ImportantFilePatterns setting --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ action.yml | 10 ++++++++++ src/Settings.schema.json | 7 +++++++ src/main.ps1 | 33 ++++++++++++++++++++++++--------- 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0c23b4d..f9473c9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,42 @@ # Get-PSModuleSettings This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule). + +## Inputs + +| Input | Description | Required | Default | +| :---- | :---------- | :------: | :------ | +| `Name` | Name of the module. | No | Repository name | +| `SettingsPath` | Path to the settings file (json, yaml/yml, or psd1). | No | | +| `ImportantFilePatterns` | Newline-separated list of regex patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. | No | `^src/` and `^README\.md$` | +| `Debug` | Enable debug output. | No | `false` | +| `Verbose` | Enable verbose output. | No | `false` | +| `Version` | Specifies the version of the GitHub module to be installed. | No | | +| `Prerelease` | Allow prerelease versions if available. | No | `false` | +| `WorkingDirectory` | The working directory where the script will run from. | No | `${{ github.workspace }}` | + +## Settings file + +The action reads settings from a file (default: `.github/PSModule.yml`). Settings in the file take precedence over action inputs. + +### ImportantFilePatterns + +Controls which file changes trigger build, test, and publish stages. When a PR only changes files that don't match any +of these patterns, those stages are skipped. + +Default patterns (used when not configured): + +- `^src/` — Module source code +- `^README\.md$` — Root documentation + +To override, add `ImportantFilePatterns` to your settings file: + +```yaml +ImportantFilePatterns: + - '^src/' + - '^README\.md$' + - '^examples/' +``` + +When configured, the provided list fully replaces the defaults. Include the default patterns in your list if you still +want them to trigger releases. diff --git a/action.yml b/action.yml index 2edc268..c669446 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,15 @@ inputs: description: The working directory where the script will run from. required: false default: ${{ github.workspace }} + ImportantFilePatterns: + description: | + Newline-separated list of regex patterns that identify important files. + Changes matching these patterns trigger build, test, and publish stages. + When set, fully replaces the defaults. + required: false + default: | + ^src/ + ^README\.md$ outputs: Settings: @@ -51,6 +60,7 @@ runs: PSMODULE_GET_SETTINGS_INPUT_Version: ${{ inputs.Version }} PSMODULE_GET_SETTINGS_INPUT_Prerelease: ${{ inputs.Prerelease }} PSMODULE_GET_SETTINGS_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }} + PSMODULE_GET_SETTINGS_INPUT_ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }} with: Name: Get-PSModuleSettings ShowInfo: false diff --git a/src/Settings.schema.json b/src/Settings.schema.json index fd489b4..ba5180e 100644 --- a/src/Settings.schema.json +++ b/src/Settings.schema.json @@ -9,6 +9,13 @@ "type": "string", "description": "The name of the module" }, + "ImportantFilePatterns": { + "type": "array", + "description": "Regex patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. Defaults to ['^src/', '^README\\.md$'] when not configured.", + "items": { + "type": "string" + } + }, "Test": { "type": "object", "description": "Test configuration settings", diff --git a/src/main.ps1 b/src/main.ps1 index d037273..2bc5c88 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -7,6 +7,7 @@ $verbose = $env:PSMODULE_GET_SETTINGS_INPUT_Verbose $version = $env:PSMODULE_GET_SETTINGS_INPUT_Version $prerelease = $env:PSMODULE_GET_SETTINGS_INPUT_Prerelease $workingDirectory = $env:PSMODULE_GET_SETTINGS_INPUT_WorkingDirectory +$importantFilePatternsInput = $env:PSMODULE_GET_SETTINGS_INPUT_ImportantFilePatterns LogGroup 'Inputs' { [pscustomobject]@{ @@ -89,8 +90,23 @@ LogGroup 'Name' { } } +LogGroup 'ImportantFilePatterns' { + $defaultImportantFilePatterns = @('^src/', '^README\.md$') + if ($settings.ImportantFilePatterns -and $settings.ImportantFilePatterns.Count -gt 0) { + $importantFilePatterns = @($settings.ImportantFilePatterns) + Write-Host "Using ImportantFilePatterns from settings file: [$($importantFilePatterns -join ', ')]" + } elseif (-not [string]::IsNullOrWhiteSpace($importantFilePatternsInput)) { + $importantFilePatterns = @($importantFilePatternsInput -split "`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ }) + Write-Host "Using ImportantFilePatterns from action input: [$($importantFilePatterns -join ', ')]" + } else { + $importantFilePatterns = $defaultImportantFilePatterns + Write-Host "Using default ImportantFilePatterns: [$($importantFilePatterns -join ', ')]" + } +} + $settings = [pscustomobject]@{ - Name = $name + Name = $name + ImportantFilePatterns = $importantFilePatterns Test = [pscustomobject]@{ Skip = $settings.Test.Skip ?? $false Linux = [pscustomobject]@{ @@ -251,11 +267,8 @@ LogGroup 'Calculate Job Run Conditions:' { Write-Host "Changed files ($($changedFiles.Count)):" $changedFiles | ForEach-Object { Write-Host " - $_" } - # Define important file patterns - $importantPatterns = @( - '^src/' - '^README\.md$' - ) + # Use configured important file patterns + $importantPatterns = $settings.ImportantFilePatterns # Check if any changed file matches an important pattern foreach ($file in $changedFiles) { @@ -276,15 +289,17 @@ LogGroup 'Calculate Job Run Conditions:' { # Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted) if ($isOpenOrUpdatedPR) { + $patternRows = ($importantPatterns | ForEach-Object { + "| ``$_`` | Matches files where path matches this pattern |" + }) -join "`n" $commentBody = @" ### No Significant Changes Detected This PR does not contain changes to files that would trigger a new release: -| Path | Description | +| Pattern | Description | | :--- | :---------- | -| ``src/**`` | Module source code | -| ``README.md`` | Documentation | +$patternRows **Build, test, and publish stages will be skipped** for this PR. From 0cd94b4696fd3a0f5fcdc93488d524258e98be0c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 27 Mar 2026 23:59:46 +0100 Subject: [PATCH 2/8] Fix linting: terminology and alignment issues --- README.md | 2 +- src/main.ps1 | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f9473c9..945af06 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This GitHub Action is a part of the [PSModule framework](https://github.com/PSMo | :---- | :---------- | :------: | :------ | | `Name` | Name of the module. | No | Repository name | | `SettingsPath` | Path to the settings file (json, yaml/yml, or psd1). | No | | -| `ImportantFilePatterns` | Newline-separated list of regex patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. | No | `^src/` and `^README\.md$` | +| `ImportantFilePatterns` | Newline-separated list of regular expression patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. | No | `^src/` and `^README\.md$` | | `Debug` | Enable debug output. | No | `false` | | `Verbose` | Enable verbose output. | No | `false` | | `Version` | Specifies the version of the GitHub module to be installed. | No | | diff --git a/src/main.ps1 b/src/main.ps1 index 2bc5c88..b53592b 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -107,7 +107,7 @@ LogGroup 'ImportantFilePatterns' { $settings = [pscustomobject]@{ Name = $name ImportantFilePatterns = $importantFilePatterns - Test = [pscustomobject]@{ + Test = [pscustomobject]@{ Skip = $settings.Test.Skip ?? $false Linux = [pscustomobject]@{ Skip = $settings.Test.Linux.Skip ?? $false @@ -163,7 +163,7 @@ $settings = [pscustomobject]@{ StepSummaryMode = $settings.Test.CodeCoverage.StepSummaryMode ?? 'Missed, Files' } } - Build = [pscustomobject]@{ + Build = [pscustomobject]@{ Skip = $settings.Build.Skip ?? $false Module = [pscustomobject]@{ Skip = $settings.Build.Module.Skip ?? $false @@ -176,7 +176,7 @@ $settings = [pscustomobject]@{ Skip = $settings.Build.Site.Skip ?? $false } } - Publish = [pscustomobject]@{ + Publish = [pscustomobject]@{ Module = [pscustomobject]@{ Skip = $settings.Publish.Module.Skip ?? $false AutoCleanup = $settings.Publish.Module.AutoCleanup ?? $true @@ -194,7 +194,7 @@ $settings = [pscustomobject]@{ UsePRTitleAsNotesHeading = $settings.Publish.Module.UsePRTitleAsNotesHeading ?? $true } } - Linter = [pscustomobject]@{ + Linter = [pscustomobject]@{ Skip = $settings.Linter.Skip ?? $false ShowSummaryOnSuccess = $settings.Linter.ShowSummaryOnSuccess ?? $false env = $settings.Linter.env ?? @{} @@ -290,8 +290,8 @@ LogGroup 'Calculate Job Run Conditions:' { # Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted) if ($isOpenOrUpdatedPR) { $patternRows = ($importantPatterns | ForEach-Object { - "| ``$_`` | Matches files where path matches this pattern |" - }) -join "`n" + "| ``$_`` | Matches files where path matches this pattern |" + }) -join "`n" $commentBody = @" ### No Significant Changes Detected From 199730c4453686896120cd2c43b6aec4172d9b3a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 28 Mar 2026 00:33:30 +0100 Subject: [PATCH 3/8] Fix top-level property alignment in settings object --- src/main.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ps1 b/src/main.ps1 index b53592b..8a006c7 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -163,7 +163,7 @@ $settings = [pscustomobject]@{ StepSummaryMode = $settings.Test.CodeCoverage.StepSummaryMode ?? 'Missed, Files' } } - Build = [pscustomobject]@{ + Build = [pscustomobject]@{ Skip = $settings.Build.Skip ?? $false Module = [pscustomobject]@{ Skip = $settings.Build.Module.Skip ?? $false @@ -176,7 +176,7 @@ $settings = [pscustomobject]@{ Skip = $settings.Build.Site.Skip ?? $false } } - Publish = [pscustomobject]@{ + Publish = [pscustomobject]@{ Module = [pscustomobject]@{ Skip = $settings.Publish.Module.Skip ?? $false AutoCleanup = $settings.Publish.Module.AutoCleanup ?? $true @@ -194,7 +194,7 @@ $settings = [pscustomobject]@{ UsePRTitleAsNotesHeading = $settings.Publish.Module.UsePRTitleAsNotesHeading ?? $true } } - Linter = [pscustomobject]@{ + Linter = [pscustomobject]@{ Skip = $settings.Linter.Skip ?? $false ShowSummaryOnSuccess = $settings.Linter.ShowSummaryOnSuccess ?? $false env = $settings.Linter.env ?? @{} From 69b84c11977b90a73b7917474f69479211a4d3d5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 28 Mar 2026 00:58:12 +0100 Subject: [PATCH 4/8] Revert README to original - docs belong in Process-PSModule --- README.md | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/README.md b/README.md index 945af06..0c23b4d 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,3 @@ # Get-PSModuleSettings This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule). - -## Inputs - -| Input | Description | Required | Default | -| :---- | :---------- | :------: | :------ | -| `Name` | Name of the module. | No | Repository name | -| `SettingsPath` | Path to the settings file (json, yaml/yml, or psd1). | No | | -| `ImportantFilePatterns` | Newline-separated list of regular expression patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. | No | `^src/` and `^README\.md$` | -| `Debug` | Enable debug output. | No | `false` | -| `Verbose` | Enable verbose output. | No | `false` | -| `Version` | Specifies the version of the GitHub module to be installed. | No | | -| `Prerelease` | Allow prerelease versions if available. | No | `false` | -| `WorkingDirectory` | The working directory where the script will run from. | No | `${{ github.workspace }}` | - -## Settings file - -The action reads settings from a file (default: `.github/PSModule.yml`). Settings in the file take precedence over action inputs. - -### ImportantFilePatterns - -Controls which file changes trigger build, test, and publish stages. When a PR only changes files that don't match any -of these patterns, those stages are skipped. - -Default patterns (used when not configured): - -- `^src/` — Module source code -- `^README\.md$` — Root documentation - -To override, add `ImportantFilePatterns` to your settings file: - -```yaml -ImportantFilePatterns: - - '^src/' - - '^README\.md$' - - '^examples/' -``` - -When configured, the provided list fully replaces the defaults. Include the default patterns in your list if you still -want them to trigger releases. From f7a67b8e8396ccad3a25139de787a1489c2d152d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 28 Mar 2026 01:03:52 +0100 Subject: [PATCH 5/8] Address review: null-aware override, regex validation, markdown escaping --- src/main.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.ps1 b/src/main.ps1 index 8a006c7..cdca65e 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -92,7 +92,7 @@ LogGroup 'Name' { LogGroup 'ImportantFilePatterns' { $defaultImportantFilePatterns = @('^src/', '^README\.md$') - if ($settings.ImportantFilePatterns -and $settings.ImportantFilePatterns.Count -gt 0) { + if ($null -ne $settings.ImportantFilePatterns) { $importantFilePatterns = @($settings.ImportantFilePatterns) Write-Host "Using ImportantFilePatterns from settings file: [$($importantFilePatterns -join ', ')]" } elseif (-not [string]::IsNullOrWhiteSpace($importantFilePatternsInput)) { @@ -102,6 +102,15 @@ LogGroup 'ImportantFilePatterns' { $importantFilePatterns = $defaultImportantFilePatterns Write-Host "Using default ImportantFilePatterns: [$($importantFilePatterns -join ', ')]" } + + # Validate that all patterns are valid regular expressions + foreach ($pattern in $importantFilePatterns) { + try { + [void][regex]::new($pattern) + } catch { + throw "Invalid regex in ImportantFilePatterns: '$pattern'. $_" + } + } } $settings = [pscustomobject]@{ @@ -290,7 +299,8 @@ LogGroup 'Calculate Job Run Conditions:' { # Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted) if ($isOpenOrUpdatedPR) { $patternRows = ($importantPatterns | ForEach-Object { - "| ``$_`` | Matches files where path matches this pattern |" + $escapedPattern = $_.Replace('|', '\|').Replace('``', '\``') + "| ``$escapedPattern`` | Matches files where path matches this pattern |" }) -join "`n" $commentBody = @" ### No Significant Changes Detected From 0ecab8488099ae18a0d15000c7ed3d210a853cbe Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 28 Mar 2026 01:13:28 +0100 Subject: [PATCH 6/8] Fix stale comment and improve backtick escaping in PR comment --- src/main.ps1 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main.ps1 b/src/main.ps1 index cdca65e..6a106a3 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -256,11 +256,7 @@ LogGroup 'Calculate Job Run Conditions:' { $isOpenOrLabeledPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize', 'labeled') # Check if important files have changed in the PR - # Important files for module and docs publish: - # - .github/workflows/Process-PSModule.yml - # - src/** - # - examples/** - # - README.md + # Important files are determined by the configured ImportantFilePatterns setting $hasImportantChanges = $false if ($isPR -and $pullRequest.Number) { LogGroup 'Check for Important File Changes' { @@ -299,8 +295,14 @@ LogGroup 'Calculate Job Run Conditions:' { # Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted) if ($isOpenOrUpdatedPR) { $patternRows = ($importantPatterns | ForEach-Object { - $escapedPattern = $_.Replace('|', '\|').Replace('``', '\``') - "| ``$escapedPattern`` | Matches files where path matches this pattern |" + $escapedPattern = $_.Replace('|', '\|') + $backtickMatches = [regex]::Matches($escapedPattern, '`+') + $maxRun = 0 + foreach ($m in $backtickMatches) { + if ($m.Value.Length -gt $maxRun) { $maxRun = $m.Value.Length } + } + $codeDelimiter = '``' * ($maxRun + 1) + "| ${codeDelimiter}${escapedPattern}${codeDelimiter} | Matches files where path matches this pattern |" }) -join "`n" $commentBody = @" ### No Significant Changes Detected From 091f664e480b56820c7da9fc81b70a427049bf2d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 28 Mar 2026 01:17:03 +0100 Subject: [PATCH 7/8] Add minLength constraint to ImportantFilePatterns schema items --- src/Settings.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Settings.schema.json b/src/Settings.schema.json index ba5180e..1e0f4bc 100644 --- a/src/Settings.schema.json +++ b/src/Settings.schema.json @@ -13,7 +13,8 @@ "type": "array", "description": "Regex patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. Defaults to ['^src/', '^README\\.md$'] when not configured.", "items": { - "type": "string" + "type": "string", + "minLength": 1 } }, "Test": { From 41cbecec13c3dec15aa43fa64520095cee3c8759 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 00:23:14 +0000 Subject: [PATCH 8/8] fix: use single backtick for code span delimiter repetition Agent-Logs-Url: https://github.com/PSModule/Get-PSModuleSettings/sessions/0d571791-16d5-4312-a8fc-200cccf5df2b Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- src/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ps1 b/src/main.ps1 index 6a106a3..83ad38a 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -301,7 +301,7 @@ LogGroup 'Calculate Job Run Conditions:' { foreach ($m in $backtickMatches) { if ($m.Value.Length -gt $maxRun) { $maxRun = $m.Value.Length } } - $codeDelimiter = '``' * ($maxRun + 1) + $codeDelimiter = '`' * ($maxRun + 1) "| ${codeDelimiter}${escapedPattern}${codeDelimiter} | Matches files where path matches this pattern |" }) -join "`n" $commentBody = @"