Skip to content

Lints inline PowerShell script steps in GitHub Actions

License

Notifications You must be signed in to change notification settings

martincostello/lint-actions-powershell

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Lint Actions PowerShell

Build status OpenSSF Scorecard

Introduction

Lints inline PowerShell script steps in GitHub Actions.

GitHub Actions workflows in the .github/workflows directory and action.yml files for custom actions are linted using PSScriptAnalyzer to check for common issues and best practices.

Issues found by PSScriptAnalyzer are emitted as GitHub Actions workflow annotations.

Examples

Basic Usage

To lint PowerShell script steps in a GitHub Actions workflow using the default rules:

steps:
- uses: actions/checkout@v4
- uses: martincostello/lint-actions-powershell@v1

Advanced Usage

steps:
- uses: actions/checkout@v4
  with:
    path: 'my-repo'
- uses: martincostello/lint-actions-powershell@v1
  with:
    annotations-title: 'lint-powershell'
    powershell-yaml-version: '0.4.12'
    psscriptanalyzer-version: '1.23.0'
    repo-path: 'my-repo'
    settings-path: 'my-repo/ScriptAnalyzerProfile.txt'
    treat-warnings-as-errors: true

Inputs

Optional

Name Description Default
annotations-title The optional title to use for workflow annotations. 'PSScriptAnalyzer'
powershell-yaml-version The optional version of the powershell-yaml module to install. Latest
psscriptanalyzer-version The optional version of the PSScriptAnalyzer module to install. Latest
repo-path The optional path to the repository containing the files to lint. github.workspace
settings-path An optional path to a file containing a user-defined profile containing settings for PSScriptAnalyzer. Default settings
treat-warnings-as-errors Whether to treat warnings as errors. false

Default Settings

The default PSScriptAnalyzer settings used are equivalent to:

@{
    IncludeDefaultRules = $true
    Severity = @("Error", "Warning")
}

Outputs

None.

Feedback

Any feedback or issues can be added to the issues for this project in GitHub.

Repository

The repository is hosted in GitHub: https://github.com/martincostello/lint-actions-powershell.git

License

This project is licensed under the Apache 2.0 license.