Skip to content

Commit e22ccce

Browse files
Add configurable ImportantFilePatterns setting
1 parent 21c88f4 commit e22ccce

4 files changed

Lines changed: 80 additions & 9 deletions

File tree

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# Get-PSModuleSettings
22

33
This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule).
4+
5+
## Inputs
6+
7+
| Input | Description | Required | Default |
8+
| :---- | :---------- | :------: | :------ |
9+
| `Name` | Name of the module. | No | Repository name |
10+
| `SettingsPath` | Path to the settings file (json, yaml/yml, or psd1). | No | |
11+
| `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$` |
12+
| `Debug` | Enable debug output. | No | `false` |
13+
| `Verbose` | Enable verbose output. | No | `false` |
14+
| `Version` | Specifies the version of the GitHub module to be installed. | No | |
15+
| `Prerelease` | Allow prerelease versions if available. | No | `false` |
16+
| `WorkingDirectory` | The working directory where the script will run from. | No | `${{ github.workspace }}` |
17+
18+
## Settings file
19+
20+
The action reads settings from a file (default: `.github/PSModule.yml`). Settings in the file take precedence over action inputs.
21+
22+
### ImportantFilePatterns
23+
24+
Controls which file changes trigger build, test, and publish stages. When a PR only changes files that don't match any
25+
of these patterns, those stages are skipped.
26+
27+
Default patterns (used when not configured):
28+
29+
- `^src/` — Module source code
30+
- `^README\.md$` — Root documentation
31+
32+
To override, add `ImportantFilePatterns` to your settings file:
33+
34+
```yaml
35+
ImportantFilePatterns:
36+
- '^src/'
37+
- '^README\.md$'
38+
- '^examples/'
39+
```
40+
41+
When configured, the provided list fully replaces the defaults. Include the default patterns in your list if you still
42+
want them to trigger releases.

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ inputs:
3131
description: The working directory where the script will run from.
3232
required: false
3333
default: ${{ github.workspace }}
34+
ImportantFilePatterns:
35+
description: |
36+
Newline-separated list of regex patterns that identify important files.
37+
Changes matching these patterns trigger build, test, and publish stages.
38+
When set, fully replaces the defaults.
39+
required: false
40+
default: |
41+
^src/
42+
^README\.md$
3443
3544
outputs:
3645
Settings:
@@ -51,6 +60,7 @@ runs:
5160
PSMODULE_GET_SETTINGS_INPUT_Version: ${{ inputs.Version }}
5261
PSMODULE_GET_SETTINGS_INPUT_Prerelease: ${{ inputs.Prerelease }}
5362
PSMODULE_GET_SETTINGS_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }}
63+
PSMODULE_GET_SETTINGS_INPUT_ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }}
5464
with:
5565
Name: Get-PSModuleSettings
5666
ShowInfo: false

src/Settings.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
"type": "string",
1010
"description": "The name of the module"
1111
},
12+
"ImportantFilePatterns": {
13+
"type": "array",
14+
"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.",
15+
"items": {
16+
"type": "string"
17+
}
18+
},
1219
"Test": {
1320
"type": "object",
1421
"description": "Test configuration settings",

src/main.ps1

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ $verbose = $env:PSMODULE_GET_SETTINGS_INPUT_Verbose
77
$version = $env:PSMODULE_GET_SETTINGS_INPUT_Version
88
$prerelease = $env:PSMODULE_GET_SETTINGS_INPUT_Prerelease
99
$workingDirectory = $env:PSMODULE_GET_SETTINGS_INPUT_WorkingDirectory
10+
$importantFilePatternsInput = $env:PSMODULE_GET_SETTINGS_INPUT_ImportantFilePatterns
1011

1112
LogGroup 'Inputs' {
1213
[pscustomobject]@{
@@ -89,8 +90,23 @@ LogGroup 'Name' {
8990
}
9091
}
9192

93+
LogGroup 'ImportantFilePatterns' {
94+
$defaultImportantFilePatterns = @('^src/', '^README\.md$')
95+
if ($settings.ImportantFilePatterns -and $settings.ImportantFilePatterns.Count -gt 0) {
96+
$importantFilePatterns = @($settings.ImportantFilePatterns)
97+
Write-Host "Using ImportantFilePatterns from settings file: [$($importantFilePatterns -join ', ')]"
98+
} elseif (-not [string]::IsNullOrWhiteSpace($importantFilePatternsInput)) {
99+
$importantFilePatterns = @($importantFilePatternsInput -split "`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ })
100+
Write-Host "Using ImportantFilePatterns from action input: [$($importantFilePatterns -join ', ')]"
101+
} else {
102+
$importantFilePatterns = $defaultImportantFilePatterns
103+
Write-Host "Using default ImportantFilePatterns: [$($importantFilePatterns -join ', ')]"
104+
}
105+
}
106+
92107
$settings = [pscustomobject]@{
93-
Name = $name
108+
Name = $name
109+
ImportantFilePatterns = $importantFilePatterns
94110
Test = [pscustomobject]@{
95111
Skip = $settings.Test.Skip ?? $false
96112
Linux = [pscustomobject]@{
@@ -251,11 +267,8 @@ LogGroup 'Calculate Job Run Conditions:' {
251267
Write-Host "Changed files ($($changedFiles.Count)):"
252268
$changedFiles | ForEach-Object { Write-Host " - $_" }
253269

254-
# Define important file patterns
255-
$importantPatterns = @(
256-
'^src/'
257-
'^README\.md$'
258-
)
270+
# Use configured important file patterns
271+
$importantPatterns = $settings.ImportantFilePatterns
259272

260273
# Check if any changed file matches an important pattern
261274
foreach ($file in $changedFiles) {
@@ -276,15 +289,17 @@ LogGroup 'Calculate Job Run Conditions:' {
276289

277290
# Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted)
278291
if ($isOpenOrUpdatedPR) {
292+
$patternRows = ($importantPatterns | ForEach-Object {
293+
"| ``$_`` | Matches files where path matches this pattern |"
294+
}) -join "`n"
279295
$commentBody = @"
280296
### No Significant Changes Detected
281297
282298
This PR does not contain changes to files that would trigger a new release:
283299
284-
| Path | Description |
300+
| Pattern | Description |
285301
| :--- | :---------- |
286-
| ``src/**`` | Module source code |
287-
| ``README.md`` | Documentation |
302+
$patternRows
288303
289304
**Build, test, and publish stages will be skipped** for this PR.
290305

0 commit comments

Comments
 (0)