Skip to content

Commit

Permalink
New pipeline to check for invalid file paths in templates.json
Browse files Browse the repository at this point in the history
  • Loading branch information
rcdailey committed Sep 2, 2023
1 parent 493890e commit a0d90ad
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/check-paths.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check Paths

on:
push:
paths:
- "sonarr/**.ya?ml"
- "sonarr/**.ya?ml"
- .github/workflows/check-paths.yml
- templates.json
pull_request:
paths:
- "sonarr/**.ya?ml"
- "sonarr/**.ya?ml"
- .github/workflows/check-paths.yml
- templates.json

jobs:
checkpaths:
name: Check Paths
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Check templates.json
run: pwsh ci/CheckInvalidTemplatePaths.ps1 templates.json
24 changes: 24 additions & 0 deletions ci/CheckInvalidTemplatePaths.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $JsonPath
)

function GetPaths($serviceType) {
Get-Content -Path $JsonPath
| ConvertFrom-Json
| ForEach-Object { $_.$serviceType.template }
}

$nonExistentFiles = $(GetPaths("radarr"); GetPaths("sonarr"))
| Where-Object {!(Test-Path -Path $_ -PathType Leaf)}


if ($nonExistentFiles.length -gt 0) {
"FAILED: More than one invalid file path found:"
Write-Host ($nonExistentFiles -join "`n")
exit 1
}

"No invalid file paths found"
exit 0

0 comments on commit a0d90ad

Please sign in to comment.