Skip to content

meewind

meewind #198

Workflow file for this run

name: meewind
on:
schedule:
- cron: "5 12 * * 5"
# push:
# branches:
# - "master"
workflow_dispatch:
jobs:
run:
runs-on: ubuntu-latest
env:
DataFolderName: ./data/meewind
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Install required PowerShell modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module UncommonSense.Hap, UncommonSense.Meewind, UncommonSense.Pushover -Scope CurrentUser
- name: Create data folder
shell: pwsh
run: |
if (-not (Test-Path -Path $env:DataFolderName -PathType Container))
{
New-Item -Path $env:DataFolderName -ItemType Directory | Out-Null
}
- name: Update fund data
shell: pwsh
run: |
$DataFileName = "$(Get-Date -Format FileDate).xml"
$DataFilePath = Join-Path -Path $env:DataFolderName -ChildPath $DataFileName
Get-MeewindFundPrice | Export-CliXml -Path $DataFilePath
- name: Clean-up data folder
shell: pwsh
run: |
Get-ChildItem -Path $env:DataFolderName
| Sort-Object Name -Descending
| Select-Object -Skip 3
| Remove-Item -Force
- name: Push changes to git repo
run: |
git config --global user.name 'Jan Hoek'
git config --global user.email 'github@uncommonsense.nl'
git remote set-url origin https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}
git add ./data/meewind/*
git commit -am 'Updated meewind files' || echo "No changes to commit"
git push
- name: Send notification
shell: pwsh
env:
PUSHOVER_APP_MEEWIND: ${{ secrets.PUSHOVER_APP_MEEWIND}}
PUSHOVER_USER_JUSTME: ${{secrets.PUSHOVER_USER_JUSTME}}
run: |
Get-ChildItem -Path $env:DataFolderName
| Import-CliXml
| Sort-Object -Property Fund, Date
| Group-Object -Property Fund
| ForEach-Object {
$Message =
$_.Group
| ForEach-Object `
-Begin {
$PreviousPrice = 0
} `
-Process {
$CurrentPrice = $_.Price
$PriceDiff = $CurrentPrice - $PreviousPrice
$FontStart, $FontStop, $Direction, $PriceDiffText = switch ($true)
{
($PreviousPrice -eq 0) { '', '', '', ''; break }
($CurrentPrice -eq $PreviousPrice) { '', '', '', ''; break }
($CurrentPrice -gt $PreviousPrice) { '<font color="#090">', '</font>', ' &#x25B2; ', ('&euro; {0}' -f $PriceDiff); break }
($CurrentPrice -lt $PreviousPrice) { '<font color="#900">', '</font>', ' &#x25BC; ', ('&euro; {0}' -f $PriceDiff); break }
}
"$($_.Date.ToString('yyyy-MM-dd')): $($FontStart)$("&euro;$($CurrentPrice)")$($Direction)$($PriceDiffText)$($FontStop)"
$PreviousPrice = $CurrentPrice
}
| Sort-Object -Descending {(++$script:Index)}
| Join-String -Separator '<br/>'
Send-PushoverNotification `
-ApplicationToken "$env:PUSHOVER_APP_MEEWIND" `
-Recipient "$env:PUSHOVER_USER_JUSTME" `
-Title "Meewind $($_.Name)" `
-Message $Message `
-Html
}