Created
September 7, 2022 11:13
-
-
Save LaurentDardenne/5d77154205f86ad4ce33be1cae5ddcb8 to your computer and use it in GitHub Desktop.
Invokebuild : task Actionlint
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
task Actionlint { | |
# Linting all workflow files only in .\.github\workflows directory | |
if (Get-Command gh.exe) | |
{ | |
$isActionLintExist=(gh extension list|Where-Object {$_ -match 'actionlint'}|Select-Object -first 1) -ne $null | |
if (-not $isActionLintExist) | |
{ Throw "Github Cli: 'actionlint' extension not found. Use : gh extension install cschleiden/gh-actionlint"} | |
$ActionLintErrors=gh actionlint -format '{{json .}}'|ConvertFrom-Json | |
$ExitCode=$LastExitCode | |
if ($ExitCode -ne 0) | |
{ | |
$ErrorFiles=$ActionLintErrors|Group-Object filepath | |
$ofs=' , ' | |
gh actionlint | |
Throw "One or more Github Action lint errors were found : $($ErrorFiles.Name). Build cannot continue." | |
} | |
} | |
else | |
{ Throw 'gh.exe (Github Cli) not found. See https://cli.github.com/'} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment