-
Notifications
You must be signed in to change notification settings - Fork 0
301 lines (283 loc) · 11.7 KB
/
workflow.yml
File metadata and controls
301 lines (283 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: Process-PSModule
on:
workflow_call:
secrets:
APIKey:
description: The API key for the PowerShell Gallery.
required: true
TEST_APP_ENT_CLIENT_ID:
description: The client ID of an Enterprise GitHub App for running tests.
required: false
TEST_APP_ENT_PRIVATE_KEY:
description: The private key of an Enterprise GitHub App for running tests.
required: false
TEST_APP_ORG_CLIENT_ID:
description: The client ID of an Organization GitHub App for running tests.
required: false
TEST_APP_ORG_PRIVATE_KEY:
description: The private key of an Organization GitHub App for running tests.
required: false
TEST_USER_ORG_FG_PAT:
description: The fine-grained personal access token with org access for running tests.
required: false
TEST_USER_USER_FG_PAT:
description: The fine-grained personal access token with user account access for running tests.
required: false
TEST_USER_PAT:
description: The classic personal access token for running tests.
required: false
inputs:
Name:
type: string
description: The name of the module to process. Scripts default to the repository name if nothing is specified.
required: false
SettingsPath:
type: string
description: The path to the settings file. Settings in the settings file take precedence over the action inputs.
required: false
default: .github/PSModule.yml
Debug:
type: boolean
description: Enable debug output.
required: false
default: false
Verbose:
type: boolean
description: Enable verbose output.
required: false
default: false
Version:
type: string
description: Specifies the version of the GitHub module to be installed. The value must be an exact version.
required: false
default: ''
Prerelease:
type: boolean
description: Whether to use a prerelease version of the 'GitHub' module.
required: false
default: false
WorkingDirectory:
type: string
description: The path to the root of the repo.
required: false
default: '.'
permissions:
contents: write # to checkout the repo and create releases on the repo
pull-requests: write # to write comments to PRs
statuses: write # to update the status of the workflow from linter
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
jobs:
Get-Settings:
uses: ./.github/workflows/Get-Settings.yml
with:
Name: ${{ inputs.Name }}
SettingsPath: ${{ inputs.SettingsPath }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Build-Module:
if: ${{ fromJson(needs.Get-Settings.outputs.Settings).Build.Module.Skip != true }}
uses: ./.github/workflows/Build-Module.yml
needs:
- Get-Settings
with:
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Build-Docs:
if: ${{ fromJson(needs.Get-Settings.outputs.Settings).Build.Docs.Skip != true }}
needs:
- Get-Settings
- Build-Module
uses: ./.github/workflows/Build-Docs.yml
with:
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Build-Site:
if: ${{ fromJson(needs.Get-Settings.outputs.Settings).Build.Site.Skip != true }}
needs:
- Get-Settings
- Build-Docs
uses: ./.github/workflows/Build-Site.yml
with:
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Test-SourceCode:
if: ${{ needs.Get-Settings.outputs.SourceCodeTestSuites != '[]' }}
needs:
- Get-Settings
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.Get-Settings.outputs.SourceCodeTestSuites) }}
uses: ./.github/workflows/Test-SourceCode.yml
with:
RunsOn: ${{ matrix.RunsOn }}
OS: ${{ matrix.OSName }}
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Lint-SourceCode:
if: ${{ needs.Get-Settings.outputs.SourceCodeTestSuites != '[]' }}
needs:
- Get-Settings
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.Get-Settings.outputs.SourceCodeTestSuites) }}
uses: ./.github/workflows/Lint-SourceCode.yml
with:
RunsOn: ${{ matrix.RunsOn }}
OS: ${{ matrix.OSName }}
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Test-Module:
if: ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-Settings.outputs.PSModuleTestSuites != '[]' }}
needs:
- Build-Module
- Get-Settings
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.Get-Settings.outputs.PSModuleTestSuites) }}
uses: ./.github/workflows/Test-Module.yml
secrets: inherit
with:
RunsOn: ${{ matrix.RunsOn }}
OS: ${{ matrix.OSName }}
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Test-ModuleLocal:
if: ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-Settings.outputs.ModuleTestSuites != '[]' }}
needs:
- Build-Module
- Get-Settings
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.Get-Settings.outputs.ModuleTestSuites) }}
uses: ./.github/workflows/Test-ModuleLocal.yml
secrets: inherit
with:
RunsOn: ${{ matrix.RunsOn }}
OS: ${{ matrix.OSName }}
TestPath: ${{ matrix.TestPath }}
TestName: ${{ matrix.TestName }}
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Get-TestResults:
if: needs.Get-Settings.result == 'success' && !fromJson(needs.Get-Settings.outputs.Settings).Test.TestResults.Skip && (needs.Get-Settings.outputs.SourceCodeTestSuites != '[]' || needs.Get-Settings.outputs.PSModuleTestSuites != '[]' || needs.Get-Settings.outputs.ModuleTestSuites != '[]') && (always() && !cancelled())
needs:
- Get-Settings
- Test-SourceCode
- Lint-SourceCode
- Test-Module
- Test-ModuleLocal
uses: ./.github/workflows/Get-TestResults.yml
secrets: inherit
with:
ModuleTestSuites: ${{ needs.Get-Settings.outputs.ModuleTestSuites }}
SourceCodeTestSuites: ${{ needs.Get-Settings.outputs.SourceCodeTestSuites }}
PSModuleTestSuites: ${{ needs.Get-Settings.outputs.PSModuleTestSuites }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
Get-CodeCoverage:
if: needs.Get-Settings.result == 'success' && !fromJson(needs.Get-Settings.outputs.Settings).Test.CodeCoverage.Skip && (needs.Get-Settings.outputs.PSModuleTestSuites != '[]' || needs.Get-Settings.outputs.ModuleTestSuites != '[]') && (always() && !cancelled())
needs:
- Get-Settings
- Test-Module
- Test-ModuleLocal
uses: ./.github/workflows/Get-CodeCoverage.yml
secrets: inherit
with:
CodeCoveragePercentTarget: ${{ fromJson(needs.Get-Settings.outputs.Settings).Test.CodeCoverage.PercentTarget }}
StepSummary_Mode: ${{ fromJson(needs.Get-Settings.outputs.Settings).Test.CodeCoverage.StepSummaryMode }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
Publish-Site:
if: ${{ needs.Get-TestResults.result == 'success' && needs.Get-CodeCoverage.result == 'success' && needs.Build-Site.result == 'success' && !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
needs:
- Get-Settings
- Get-TestResults
- Get-CodeCoverage
- Build-Site
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Publish-Module:
if: ${{ needs.Get-Settings.result == 'success' && needs.Get-TestResults.result == 'success' && needs.Get-CodeCoverage.result == 'success' && needs.Build-Site.result == 'success' && !cancelled() && github.event_name == 'pull_request' }}
needs:
- Get-Settings
- Get-TestResults
- Get-CodeCoverage
- Build-Site
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download module artifact
uses: actions/download-artifact@v5
with:
name: module
path: ${{ inputs.WorkingDirectory }}/outputs/module
- name: Update Microsoft.PowerShell.PSResourceGet
shell: pwsh
run: |
Install-PSResource -Name Microsoft.PowerShell.PSResourceGet -Repository PSGallery -TrustRepository
- name: Publish module
uses: PSModule/Publish-PSModule@v2
env:
GH_TOKEN: ${{ github.token }}
with:
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
ModulePath: outputs/module
APIKey: ${{ secrets.APIKEY }}
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
AutoCleanup: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.AutoCleanup }}
AutoPatching: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.AutoPatching }}
DatePrereleaseFormat: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.DatePrereleaseFormat }}
IgnoreLabels: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.IgnoreLabels }}
IncrementalPrerelease: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.IncrementalPrerelease }}
MajorLabels: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.MajorLabels }}
MinorLabels: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.MinorLabels }}
PatchLabels: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.PatchLabels }}
VersionPrefix: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.VersionPrefix }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}