Skip to content

Commit

Permalink
feat: Recommendation Object Pipeline (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpoineal authored Sep 19, 2024
1 parent f096646 commit 2a305f3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/scripts/build-recommendation-object.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import-module powershell-yaml -force -scope CurrentUser

function Build-APRLJsonObject {
param (
[string]$path
)

$kqlfiles = Get-ChildItem -Path $path -Recurse -Filter "*.kql"
$yamlfiles = Get-ChildItem -Path $path -Recurse -Filter "*.yaml"

$yamlobj = foreach($file in $yamlfiles){
$content = Get-Content $file.FullName -Raw | ConvertFrom-Yaml
$content | Select-Object publishedToAdvisor,aprlGuid,recommendationTypeId,recommendationMetadataState,learnMoreLink,recommendationControl,longDescription,pgVerified,description,potentialBenefits,publishedToLearn,tags,recommendationResourceType,recommendationImpact,automationAvailable,query
}

$kqlobj = foreach($file in $kqlfiles){
$content = Get-Content $file.FullName -Raw
[PSCustomObject]@{
AprlGUID = $file.Name -replace ".kql",""
Query = $content
}
}

$aprlobj = foreach($obj in $yamlobj){
$obj.query = $($kqlobj.Where{$_.AprlGUID -eq $obj.aprlGuid}).Query
$obj
}
return $aprlobj
}

try{
Build-APRLJsonObject -path "./azure-resources" | ConvertTo-Json -Depth 10 | Out-File -FilePath "./tools/data/recommendations.json" -Force
exit 0
}
catch{
Write-Error $_.Exception.Message
exit 1
}
19 changes: 19 additions & 0 deletions .github/workflows/build-recommendation-object.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Nightly Recommendation Object Build

on:
schedule:
- cron: "0 0 * * *"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main

- name: Run Recommendation Object Builder
run: |
pwsh .github/scripts/build-recommendation-object.ps1

0 comments on commit 2a305f3

Please sign in to comment.