Replaced old powershell action with Azure action #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Workflow | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
pull_request: | |
branches: | |
- dev | |
workflow_dispatch: | |
jobs: | |
lint: | |
name: Static Code Analysis with PSScriptAnalyzer and DevSkim | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up PowerShell | |
uses: Azure/powershell-action@v1 | |
with: | |
azure-powershell-version: "latest" # Or specify a version like "7.2.0" | |
- name: Install PSScriptAnalyzer | |
run: | | |
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser | |
shell: pwsh | |
- name: Run PSScriptAnalyzer | |
run: | | |
Invoke-ScriptAnalyzer -Path ./WSTools -Recurse -Severity Warning,Error | |
shell: pwsh | |
- name: Install DevSkim | |
run: | | |
choco install devskim -y | |
shell: cmd | |
- name: Run DevSkim Analysis | |
run: | | |
devskim analyze --directory ./WSTools --output-format sarif --output-file devskim-results.sarif --severity warning,error | |
shell: cmd | |
- name: Upload SARIF File | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: devskim-results.sarif | |
test: | |
name: Run Tests | |
needs: lint | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up PowerShell | |
uses: Azure/powershell-action@v1 | |
with: | |
azure-powershell-version: "latest" # Or specify a version like "7.2.0" | |
- name: Install Pester | |
run: | | |
Install-Module -Name Pester -Force -Scope CurrentUser | |
shell: pwsh | |
- name: Run Pester Tests | |
run: | | |
Invoke-Pester -Path ./WSTools/Tests | |
shell: pwsh | |
publish: | |
name: Publish to PowerShell Gallery | |
needs: test | |
if: github.ref == 'refs/heads/main' | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up PowerShell | |
uses: Azure/powershell-action@v1 | |
with: | |
azure-powershell-version: "latest" # Or specify a version like "7.2.0" | |
- name: Publish Module | |
run: | | |
$apiKey = "${{ secrets.PSGALLERY_API_KEY }}" | |
Publish-Module -Path ./WSTools -NuGetApiKey $apiKey | |
shell: pwsh |