Skip to content

Instantly share code, notes, and snippets.

@LaurentDardenne
Created September 7, 2022 11:13
Show Gist options
  • Save LaurentDardenne/5d77154205f86ad4ce33be1cae5ddcb8 to your computer and use it in GitHub Desktop.
Save LaurentDardenne/5d77154205f86ad4ce33be1cae5ddcb8 to your computer and use it in GitHub Desktop.
Invokebuild : task Actionlint
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