-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (64 loc) · 2.46 KB
/
main.yml
File metadata and controls
73 lines (64 loc) · 2.46 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
name: Test PowerShell on Ubuntu
# Controls when the workflow will run
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow
on:
push:
release:
types: [created]
jobs:
lint-with-PSScriptAnalyzer:
name: Install and run PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out repository code
uses: actions/checkout@v3
- name: Install PSScriptAnalyzer module
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path *.ps1 -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
pester-test:
name: Test module and upload results
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Test with Pester
shell: pwsh
run: Invoke-Pester -Passthru | Export-Clixml -Path Module.Tests.xml
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ubuntu-Module-Tests
path: ./Module.Tests.xml
# The always() function configures the job to continue processing even if there are test failures. For more information, see "always."
if: ${{ always() }}
publish-to-gallery:
name: Publish module
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Publish
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
shell: pwsh
run: |
New-Item -Path "./Output/PSGithubUtils" -ItemType Directory
Copy-Item -Path "./PSGithubUtils/*" -Destination "./Output/PSGithubUtils" -Recurse
Publish-Module -Path "./Output/PSGithubUtils" -NuGetApiKey $env:NUGET_KEY -Verbose
# Only publish on release
if: ${{ github.event_name == 'release' }}
needs: [lint-with-PSScriptAnalyzer, pester-test]