Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
10 changes: 10 additions & 0 deletions 10 action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions 8 src/Settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"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",
"minLength": 1
}
},
"Test": {
"type": "object",
"description": "Test configuration settings",
Expand Down
63 changes: 45 additions & 18 deletions 63 src/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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]@{
Expand Down Expand Up @@ -89,9 +90,33 @@ LogGroup 'Name' {
}
}

LogGroup 'ImportantFilePatterns' {
$defaultImportantFilePatterns = @('^src/', '^README\.md$')
if ($null -ne $settings.ImportantFilePatterns) {
$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 ', ')]"
}

Comment thread
MariusStorhaug marked this conversation as resolved.
# 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]@{
Name = $name
Test = [pscustomobject]@{
Name = $name
ImportantFilePatterns = $importantFilePatterns
Test = [pscustomobject]@{
Skip = $settings.Test.Skip ?? $false
Linux = [pscustomobject]@{
Skip = $settings.Test.Linux.Skip ?? $false
Expand Down Expand Up @@ -147,7 +172,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
Expand All @@ -160,7 +185,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
Expand All @@ -178,7 +203,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 ?? @{}
Expand Down Expand Up @@ -231,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' {
Expand All @@ -251,11 +272,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
Comment thread
MariusStorhaug marked this conversation as resolved.
Comment thread
MariusStorhaug marked this conversation as resolved.

# Check if any changed file matches an important pattern
foreach ($file in $changedFiles) {
Expand All @@ -276,15 +294,24 @@ 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('|', '\|')
$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

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.

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.