1515 . EXAMPLE
1616 ./.github/scripts/Get-ProcessPSModuleWorkflowInventory.ps1 `
1717 -Organization PSModule `
18+ -TargetReference v8 `
1819 -JsonPath ./output/process-workflows.json `
1920 -MarkdownPath ./output/process-workflows.md
2021
@@ -45,6 +46,10 @@ param(
4546 [ValidateNotNullOrEmpty ()]
4647 [string ] $WorkflowReference = ' PSModule/Process-PSModule/.github/workflows/workflow.yml' ,
4748
49+ [Parameter ()]
50+ [ValidateNotNullOrEmpty ()]
51+ [string ] $TargetReference ,
52+
4853 [Parameter ()]
4954 [string ] $JsonPath ,
5055
@@ -458,7 +463,10 @@ function Get-WorkflowInventoryItem {
458463 [psobject ] $WorkflowFile ,
459464
460465 [Parameter (Mandatory )]
461- [string ] $ExpectedReference
466+ [string ] $ExpectedReference ,
467+
468+ [Parameter ()]
469+ [string ] $ExpectedTargetReference
462470 )
463471
464472 if ($WorkflowFile.Content -notmatch [regex ]::Escape($ExpectedReference )) {
@@ -495,6 +503,11 @@ function Get-WorkflowInventoryItem {
495503 Name = $jobName
496504 Uses = " $uses "
497505 Reference = " $uses " .Substring(" $ExpectedReference @" .Length)
506+ MatchesTarget = if ($ExpectedTargetReference ) {
507+ " $uses " .Substring(" $ExpectedReference @" .Length) -eq $ExpectedTargetReference
508+ } else {
509+ $null
510+ }
498511 Inputs = ConvertTo-StringMap - Map (Get-MapValue - Map $job - Name ' with' )
499512 SecretMode = $secretMode
500513 SecretMappings = if ($secretMode -eq ' explicit' ) {
@@ -595,6 +608,12 @@ function Get-WorkflowInventoryItem {
595608 ProcessJobs = @ ($processJobs )
596609 AdditionalJobs = @ ($allJobNames | Where-Object { $_ -notin $processJobNames })
597610 VersionComments = $versionComments
611+ TargetReference = $ExpectedTargetReference
612+ MatchesTarget = if ($ExpectedTargetReference ) {
613+ @ ($processJobs | Where-Object { -not $_.MatchesTarget }).Count -eq 0
614+ } else {
615+ $null
616+ }
598617 }
599618}
600619
@@ -621,7 +640,10 @@ function ConvertTo-WorkflowInventoryMarkdown {
621640
622641 [Parameter (Mandatory )]
623642 [ValidateSet (' GitHub' , ' Local' )]
624- [string ] $Source
643+ [string ] $Source ,
644+
645+ [Parameter ()]
646+ [string ] $TargetReference
625647 )
626648
627649 $parsed = @ ($Inventory | Where-Object Status -eq ' Parsed' )
@@ -660,6 +682,11 @@ function ConvertTo-WorkflowInventoryMarkdown {
660682 $lines.Add (" - Workflow files: $ ( $Inventory.Count ) " )
661683 $lines.Add (" - Parsed: $ ( $parsed.Count ) " )
662684 $lines.Add (" - Parse errors: $ ( $parseErrors.Count ) " )
685+ if ($TargetReference ) {
686+ $matchingTarget = @ ($parsed | Where-Object MatchesTarget).Count
687+ $lines.Add (" - Target reference: $TargetReference " )
688+ $lines.Add (" - Matching target: $matchingTarget /$ ( $parsed.Count ) " )
689+ }
663690 $lines.Add (' ' )
664691 $lines.Add (' ## Reference distribution' )
665692 $lines.Add (' ' )
@@ -688,11 +715,11 @@ function ConvertTo-WorkflowInventoryMarkdown {
688715 $lines.Add (' ## Workflow files' )
689716 $lines.Add (' ' )
690717 $lines.Add (
691- ' | Repository | File | Name | Run name | Events | Reference | Version | PR types | Push branches | Schedule |' +
692- ' Concurrency | Cancel | Permissions | Condition | Secrets | Inputs | Extra jobs |'
718+ ' | Repository | File | Name | Run name | Events | Reference | Target | Version | PR types | Push branches |' +
719+ ' Schedule | Concurrency | Cancel | Permissions | Condition | Secrets | Inputs | Extra jobs |'
693720 )
694721 $lines.Add (
695- ' | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |'
722+ ' | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | '
696723 )
697724
698725 foreach ($item in $Inventory | Sort-Object Repository, WorkflowPath) {
@@ -710,7 +737,7 @@ function ConvertTo-WorkflowInventoryMarkdown {
710737 if ($item.Status -eq ' ParseError' ) {
711738 $lines.Add (
712739 " | $ ( ConvertTo-MarkdownCell $repositoryCell ) " +
713- " | $ ( ConvertTo-MarkdownCell $workflowCell ) | parse error | | | | | | | | | | | | | | |"
740+ " | $ ( ConvertTo-MarkdownCell $workflowCell ) | parse error | | | | | | | | | | | | | | | | "
714741 )
715742 continue
716743 }
@@ -749,6 +776,7 @@ function ConvertTo-WorkflowInventoryMarkdown {
749776 " | $ ( ConvertTo-MarkdownCell $item.RunName ) " +
750777 " | $ ( ConvertTo-MarkdownCell $item.Events ) " +
751778 " | $ ( ConvertTo-MarkdownCell $referencesForItem ) " +
779+ " | $ ( ConvertTo-MarkdownCell $item.MatchesTarget ) " +
752780 " | $ ( ConvertTo-MarkdownCell $versionsForItem ) " +
753781 " | $ ( ConvertTo-MarkdownCell $item.PullRequestTypes ) " +
754782 " | $ ( ConvertTo-MarkdownCell $item.PushBranches ) " +
@@ -805,7 +833,10 @@ if (-not $workflowFiles) {
805833$inventory = @ (
806834 $workflowFiles |
807835 ForEach-Object {
808- Get-WorkflowInventoryItem - WorkflowFile $_ - ExpectedReference $WorkflowReference
836+ Get-WorkflowInventoryItem `
837+ - WorkflowFile $_ `
838+ - ExpectedReference $WorkflowReference `
839+ - ExpectedTargetReference $TargetReference
809840 }
810841)
811842
@@ -829,7 +860,8 @@ if ($MarkdownPath) {
829860 }
830861 ConvertTo-WorkflowInventoryMarkdown `
831862 - Inventory $inventory `
832- - Source $PSCmdlet.ParameterSetName |
863+ - Source $PSCmdlet.ParameterSetName `
864+ - TargetReference $TargetReference |
833865 Set-Content - LiteralPath $MarkdownPath - Encoding utf8
834866}
835867
0 commit comments