1818 steps :
1919 - uses : actions/checkout@v6
2020
21+ # Skip lint on the un-initialized template — the literal `./{{ModuleName}}`
22+ # path argument can't be parsed by PowerShell (the double braces split into
23+ # mismatched script-block delimiters), so Invoke-ScriptAnalyzer fails with
24+ # a positional-argument error before it ever touches the folder. Same
25+ # marker as the unit-tests job below.
26+ - name : Detect template state
27+ id : template_guard
28+ shell : bash
29+ run : |
30+ if [ -f CHANGELOG.template.md ]; then
31+ echo "is_template=true" >> "$GITHUB_OUTPUT"
32+ else
33+ echo "is_template=false" >> "$GITHUB_OUTPUT"
34+ fi
35+
2136 - name : Cache PowerShell modules
37+ if : steps.template_guard.outputs.is_template == 'false'
2238 id : cache-lint-modules
2339 uses : actions/cache@v5
2440 with :
@@ -28,13 +44,14 @@ jobs:
2844 ${{ runner.os }}-psmodules-lint-
2945
3046 - name : Install PSScriptAnalyzer
31- if : steps.cache-lint-modules.outputs.cache-hit != 'true'
47+ if : steps.template_guard.outputs.is_template == 'false' && steps. cache-lint-modules.outputs.cache-hit != 'true'
3248 shell : pwsh
3349 run : |
3450 Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
3551 Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
3652
3753 - name : Run PSScriptAnalyzer
54+ if : steps.template_guard.outputs.is_template == 'false'
3855 shell : pwsh
3956 run : |
4057 $results = Invoke-ScriptAnalyzer -Path ./{{ModuleName}} -Recurse -Settings PSGallery -ReportSummary
6380 steps :
6481 - uses : actions/checkout@v6
6582
83+ # Skip subsequent steps on the un-initialized template — Build's
84+ # GENERATEMARKDOWN task can't import the manifest while {{GUID}} is still
85+ # a literal placeholder. Marker: CHANGELOG.template.md exists only
86+ # pre-init; Initialize-Template.ps1 moves it onto CHANGELOG.md during
87+ # init, so downstream repos run the full job. The marker path contains
88+ # no placeholder token, so init's substitution loop leaves this guard
89+ # intact when the workflow is copied into a new module.
90+ # hashFiles() is not allowed in jobs.<job_id>.if, so we evaluate it in a
91+ # step and gate downstream steps on the resulting output.
92+ - name : Detect template state
93+ id : template_guard
94+ shell : bash
95+ run : |
96+ if [ -f CHANGELOG.template.md ]; then
97+ echo "is_template=true" >> "$GITHUB_OUTPUT"
98+ else
99+ echo "is_template=false" >> "$GITHUB_OUTPUT"
100+ fi
101+
66102 - name : Cache PowerShell modules
103+ if : steps.template_guard.outputs.is_template == 'false'
67104 uses : actions/cache@v5
68105 with :
69106 path : |
@@ -74,23 +111,24 @@ jobs:
74111 ${{ runner.os }}-psmodules-
75112
76113 - name : Build and Test
114+ if : steps.template_guard.outputs.is_template == 'false'
77115 shell : pwsh
78116 run : |
79117 New-Item -Path out -ItemType Directory -Force | Out-Null
80118 ./build.ps1 -Task Build,Test -Bootstrap
81119
82120 - name : Upload Coverage to Codecov
121+ if : success() && steps.template_guard.outputs.is_template == 'false'
83122 uses : codecov/codecov-action@v6
84- if : success()
85123 with :
86124 token : ${{ secrets.CODECOV_TOKEN }}
87125 files : out/codeCoverage.xml
88126 flags : ${{ matrix.os }}
89127 fail_ci_if_error : false
90128
91129 - name : Upload Test Results
130+ if : always() && steps.template_guard.outputs.is_template == 'false'
92131 uses : actions/upload-artifact@v7
93- if : always()
94132 with :
95133 name : test-results-${{ matrix.os }}
96134 path : out/
0 commit comments