Skip to content

Commit 1111791

Browse files
MariusStorhaugCopilotCopilot
authored
🚀 [Feature]: Release-triggering file patterns now configurable via workflow input (#301)
Repositories can now control which file changes trigger build, test, and publish stages by configuring the `ImportantFilePatterns` workflow input or settings file property. The default patterns (`^src/` and `^README\.md$`) remain unchanged for backward compatibility. - Fixes #278 ## New: Configurable release-triggering file patterns The `ImportantFilePatterns` input is now available on the `workflow.yml` and `Get-Settings.yml` reusable workflows. Pass a newline-separated list of regex patterns to override the defaults: ```yaml jobs: Process: uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v5 with: ImportantFilePatterns: | ^src/ ^README\.md$ ^examples/ ``` To disable file-change triggering entirely, pass an empty string via the workflow input or set an empty list in `.github/PSModule.yml`: ```yaml # In .github/PSModule.yml ImportantFilePatterns: [] ``` Resolution order: settings file → workflow input → workflow input default values. ## Changed: PR comment reflects configured patterns The automated comment posted on PRs when no important files are changed now dynamically lists the configured patterns instead of a hardcoded table. ## Technical Details - Added `ImportantFilePatterns` input (type: `string`, newline-separated) to both `.github/workflows/workflow.yml` and `.github/workflows/Get-Settings.yml` with explicit defaults (`^src/` and `^README\.md$`). - Bumped `Get-PSModuleSettings` action reference from `v1.4.4` to `v1.5.0` which implements the settings file and action input support for this feature. - Passed `ImportantFilePatterns` input through the reusable workflow chain to the `Get-PSModuleSettings` action step. - Updated README documentation: new input in the workflow inputs table, new "Customizing important file patterns" section with YAML examples, updated settings file reference and example schema. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 3ed96da commit 1111791

File tree

3 files changed

+84
-13
lines changed

3 files changed

+84
-13
lines changed

‎.github/workflows/Get-Settings.yml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ on:
3232
description: The path to the root of the repo.
3333
required: false
3434
default: '.'
35+
ImportantFilePatterns:
36+
type: string
37+
description: |
38+
Newline-separated list of regex patterns that identify important files.
39+
Changes matching these patterns trigger build, test, and publish stages.
40+
When set, fully replaces the defaults (^src/ and ^README\.md$).
41+
required: false
42+
default: |
43+
^src/
44+
^README\.md$
3545
3646
outputs:
3747
Settings:
@@ -56,7 +66,7 @@ jobs:
5666
fetch-depth: 0
5767

5868
- name: Get-Settings
59-
uses: PSModule/Get-PSModuleSettings@21c88f499579f56a60cced37872089d866b94a66 # v1.4.4
69+
uses: PSModule/Get-PSModuleSettings@1e3d156786c56e6fbd839a1ba5ab21ff8858090e # v1.5.0
6070
id: Get-Settings
6171
with:
6272
SettingsPath: ${{ inputs.SettingsPath }}
@@ -65,3 +75,4 @@ jobs:
6575
Verbose: ${{ inputs.Verbose }}
6676
Version: ${{ inputs.Version }}
6777
WorkingDirectory: ${{ inputs.WorkingDirectory }}
78+
ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }}

‎.github/workflows/workflow.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ on:
5858
description: The path to the root of the repo.
5959
required: false
6060
default: '.'
61+
ImportantFilePatterns:
62+
type: string
63+
description: |
64+
Newline-separated list of regex patterns that identify important files.
65+
Changes matching these patterns trigger build, test, and publish stages.
66+
When set, fully replaces the defaults (^src/ and ^README\.md$).
67+
required: false
68+
default: |
69+
^src/
70+
^README\.md$
6171
6272
permissions:
6373
contents: write # to checkout the repo and create releases on the repo
@@ -81,6 +91,7 @@ jobs:
8191
Verbose: ${{ inputs.Verbose }}
8292
Version: ${{ inputs.Version }}
8393
WorkingDirectory: ${{ inputs.WorkingDirectory }}
94+
ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }}
8495

8596
# Runs on:
8697
# - ✅ Open/Updated PR - Lints code changes in active PRs

‎README.md‎

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Depending on the labels in the pull requests, the [workflow will result in diffe
7575
- [Scenario Matrix](#scenario-matrix)
7676
- [Important file change detection](#important-file-change-detection)
7777
- [Files that trigger releases](#files-that-trigger-releases)
78-
- [Files that do NOT trigger releases](#files-that-do-not-trigger-releases)
78+
- [Customizing important file patterns](#customizing-important-file-patterns)
7979
- [Behavior when no important files are changed](#behavior-when-no-important-files-are-changed)
8080
- [Configuration](#configuration)
8181
- [Example 1 - Defaults with Code Coverage target](#example-1---defaults-with-code-coverage-target)
@@ -392,6 +392,7 @@ jobs:
392392
| `Version` | `string` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | `false` | `''` |
393393
| `Prerelease` | `boolean` | Whether to use a prerelease version of the 'GitHub' module. | `false` | `false` |
394394
| `WorkingDirectory` | `string` | The path to the root of the repo. | `false` | `'.'` |
395+
| `ImportantFilePatterns` | `string` | Newline-separated list of regular expression patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. When set, fully replaces the defaults. | `false` | `^src/\n^README\.md$` |
395396

396397
### Secrets
397398

@@ -458,26 +459,69 @@ settings, or test files) are modified.
458459

459460
#### Files that trigger releases
460461

461-
| Path | Description |
462+
By default, the following regular expression patterns identify important files:
463+
464+
| Pattern | Description |
462465
| :--- | :---------- |
463-
| `src/**` | Module source code |
464-
| `README.md` | Module documentation |
466+
| `^src/` | Module source code |
467+
| `^README\.md$` | Module documentation |
468+
469+
#### Customizing important file patterns
470+
471+
To override the default patterns, set `ImportantFilePatterns` in your settings file (`.github/PSModule.yml`):
472+
473+
```yaml
474+
ImportantFilePatterns:
475+
- '^src/'
476+
- '^README\.md$'
477+
- '^examples/'
478+
```
465479

466-
#### Files that do NOT trigger releases
480+
When configured, the provided list fully replaces the defaults. Include the default patterns in your list if you still
481+
want them to trigger releases.
467482

468-
Changes to the following files will not trigger a release:
483+
To disable file-change triggering entirely (so that no file changes ever trigger a release), set an empty list in the
484+
settings file:
469485

470-
- `.github/workflows/*` - Workflow configurations
471-
- `.github/linters/*` - Linter configuration files
472-
- `tests/**` - Test files
473-
- `examples/**` - Example scripts
474-
- `.gitignore`, `.editorconfig`, etc. - Repository configuration files
486+
```yaml
487+
ImportantFilePatterns: []
488+
```
489+
490+
You can also pass patterns via the workflow input:
491+
492+
```yaml
493+
jobs:
494+
Process:
495+
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v5
496+
with:
497+
ImportantFilePatterns: |
498+
^src/
499+
^README\.md$
500+
^examples/
501+
```
502+
503+
To disable triggering via the workflow input, pass an explicit empty string:
504+
505+
```yaml
506+
jobs:
507+
process:
508+
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v5
509+
with:
510+
ImportantFilePatterns: ''
511+
```
512+
513+
Note that omitting the `ImportantFilePatterns` key entirely causes the workflow's default patterns (`^src/` and
514+
`^README\.md$`) to be used. The settings file takes priority over the workflow input, so set
515+
`ImportantFilePatterns: []` in `.github/PSModule.yml` to disable triggering regardless of the workflow input.
516+
517+
Resolution order: settings file → workflow input → workflow input default values.
475518

476519
#### Behavior when no important files are changed
477520

478521
When a pull request does not contain changes to important files:
479522

480-
1. A comment is automatically added to the PR explaining why build/test stages are skipped
523+
1. A comment is automatically added to the PR listing the configured patterns and explaining why build/test stages are
524+
skipped
481525
2. The `ReleaseType` output is set to `None`
482526
3. Build, test, and publish stages are skipped
483527
4. The PR can still be merged for non-release changes (documentation updates, CI improvements, etc.)
@@ -495,6 +539,7 @@ The following settings are available in the settings file:
495539
| Name | Type | Description | Default |
496540
| ----------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
497541
| `Name` | `String` | Name of the module to publish. Defaults to the repository name. | `null` |
542+
| `ImportantFilePatterns` | `Array` | Regular expression patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. When set, fully replaces the defaults. | `['^src/', '^README\.md$']` |
498543
| `Test.Skip` | `Boolean` | Skip all tests | `false` |
499544
| `Test.Linux.Skip` | `Boolean` | Skip tests on Linux | `false` |
500545
| `Test.MacOS.Skip` | `Boolean` | Skip tests on macOS | `false` |
@@ -543,6 +588,10 @@ The following settings are available in the settings file:
543588
```yaml
544589
Name: null
545590
591+
ImportantFilePatterns:
592+
- '^src/'
593+
- '^README\.md$'
594+
546595
Build:
547596
Skip: false
548597
Module:

0 commit comments

Comments
 (0)