Skip to content

watchdog

watchdog #877

Workflow file for this run

name: watchdog
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install required PowerShell modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module UncommonSense.Rss -Scope CurrentUser
- name: Find latest updates
shell: pwsh
run: |
$Today = Get-Date
$Body =
Get-ChildItem -Path ./data/*.xml -Exclude watchdog.xml
| ForEach-Object {
$CurrentFile = $_
$LatestPubDate = Select-Xml -Path $_.FullName -XPath '/rss/channel/item/pubDate/text()'
| Select-Object -ExpandProperty Node
| Select-Object -ExpandProperty Value
| ForEach-Object { [DateTime]::ParseExact($_, 'ddd, d MMM yyyy HH:mm:ss zzz', [CultureInfo]::InvariantCulture) }
| Sort-Object -Descending
| Select-Object -First 1
[PSCustomObject]@{
FileName = $CurrentFile.Name
LatestPubDate = $LatestPubDate
Age = -($LatestPubDate - $Today)
}
}
| Sort-Object LatestPubDate -Descending
| ForEach-Object `
-Begin { '<table>', '<tr><th>File Name</th><th>Latest Publication Date</th><th>Age in Days</th></tr>' } `
-Process { "<tr><td>$($_.FileName)</td><td>$($_.LatestPubDate)</td><td>$($_.Age.Days)</td></tr>" } `
-End { '</table>'}
New-RssFeedItem -Title "Watchdog $(Get-Date)" -Description ($Body -join "`n")
| New-RssFeed -Title Watchdog -Description Watchdog -Link 'http://github.com/jhoek/kibitzr'
| Set-Content -Path ./data/watchdog.xml
- name: Commit and push feed
shell: bash
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git pull
git add .
git commit -m "generated" || echo "No changes to commit"
git push