Noodband genereren #253
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Noodband genereren | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '31 1 * * *' | |
jobs: | |
record-audio: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install ffmpeg | |
run: sudo apt-get update && sudo apt-get install -y ffmpeg | |
- name: Wait for top of the hour | |
run: | | |
CURRENT_MINUTE=$(date +%M) | |
CURRENT_SECOND=$(date +%S) | |
SECONDS_TO_NEXT_HOUR=$(( (60 - $CURRENT_MINUTE) * 60 - $CURRENT_SECOND )) | |
echo "Waiting $SECONDS_TO_NEXT_HOUR seconds for the top of the hour." | |
sleep $SECONDS_TO_NEXT_HOUR | |
- name: Record audio | |
run: ffmpeg -i https://icecast.zuidwestfm.nl/zuidwest.stl -t 02:59:59 -acodec pcm_s16le audio.wav | |
- name: Upload recorded audio | |
uses: actions/upload-artifact@v4 | |
with: | |
name: recorded-audio | |
path: audio.wav | |
process-audio: | |
runs-on: windows-latest | |
needs: record-audio | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Insert StereoTool license key | |
run: | | |
$path = "WatchCat.ini" | |
(Get-Content $path) -replace '<place_st_code_here>', '${{ secrets.ST_LICENSE }}' | Set-Content $path | |
shell: pwsh | |
- name: Create Input and Output directories | |
shell: pwsh | |
run: | | |
New-Item -ItemType directory -Path "${{ github.workspace }}/input" -Force | |
New-Item -ItemType directory -Path "${{ github.workspace }}/output" -Force | |
- name: Download recorded audio | |
uses: actions/download-artifact@v4 | |
with: | |
name: recorded-audio | |
path: "${{ github.workspace }}/input" | |
- name: Download Thimeo WatchCat | |
run: Invoke-WebRequest -Uri "https://www.stereotool.com/download/ThimeoWatchCat_installer_64.exe" -OutFile "ThimeoWatchCat_installer_64.exe" | |
- name: Install Thimeo WatchCat | |
shell: pwsh | |
run: | | |
Start-Process -FilePath ".\ThimeoWatchCat_installer_64.exe" -ArgumentList '/S' | |
Start-Sleep -Seconds 15 | |
- name: Copy WatchCat.ini to AppData | |
shell: pwsh | |
run: | | |
$sourcePath = "${{ github.workspace }}/WatchCat.ini" | |
$destPath = "$HOME/AppData/Roaming/Thimeo Audio Technology B.V./WatchCat.ini" | |
New-Item -ItemType Directory -Path "$HOME/AppData/Roaming/Thimeo Audio Technology B.V." -Force | |
Copy-Item -Path $sourcePath -Destination $destPath | |
- name: Check if config file exists | |
shell: pwsh | |
run: | | |
$configPath = "$HOME/AppData/Roaming/Thimeo Audio Technology B.V./WatchCat.ini" | |
if (Test-Path $configPath) { | |
Write-Output "Config file exists." | |
} else { | |
Write-Output "Config file does not exist." | |
exit 1 | |
} | |
- name: Run Thimeo WatchCat to generate audio file | |
shell: pwsh | |
run: | | |
$exePath = "C:\Program Files\Thimeo\WatchCat\ThimeoWatchCat.exe" | |
if (Test-Path $exePath) { | |
$process = Start-Process -FilePath $exePath -PassThru | |
Write-Output "ThimeoWatchCat.exe started with PID: $($process.Id)" | |
} else { | |
Write-Output "ThimeoWatchCat.exe not found." | |
} | |
- name: Take Screenshot | |
shell: pwsh | |
run: | | |
Start-Sleep -Seconds 20 | |
./screenshot.ps1 | |
- name: Upload Screenshot | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots | |
path: "C:/ScreenCapture" | |
- name: Wait for WatchCat to finish | |
shell: pwsh | |
run: | | |
$processedPath = "${{ github.workspace }}/input/Processed" | |
$failedPath = "${{ github.workspace }}/input/Failed" | |
while (-not (Test-Path $processedPath)) { | |
if (Test-Path $failedPath) { | |
Write-Output "Processing failed, 'Failed' directory found." | |
exit 1 | |
} | |
Start-Sleep -Seconds 10 | |
Write-Output "Waiting for 'Processed' directory to appear..." | |
} | |
- name: Output contents of the output directory | |
shell: pwsh | |
run: | | |
Get-ChildItem "${{ github.workspace }}/output" | ForEach-Object { Write-Output $_.FullName } | |
- name: Upload processed file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: processed-audio | |
path: "${{ github.workspace }}/output" | |
upload-audio: | |
runs-on: ubuntu-latest | |
needs: process-audio | |
steps: | |
- name: Download audio | |
uses: actions/download-artifact@v4 | |
- name: Install WireGuard | |
run: sudo apt-get update && sudo apt-get install -y wireguard | |
- name: Generate public key for WireGuard | |
id: generate-keys | |
run: | | |
PRIVATE_KEY="${{ secrets.WG_DEVICE_PRIVATE_KEY }}" | |
echo "PRIVATE_KEY=$PRIVATE_KEY" > $GITHUB_ENV | |
PUBLIC_KEY=$(echo "$PRIVATE_KEY" | wg pubkey) | |
echo "PUBLIC_KEY=$PUBLIC_KEY" >> $GITHUB_ENV | |
- name: Configure WireGuard | |
run: | | |
sudo bash -c "cat >/etc/wireguard/wg0.conf <<EOL | |
[Interface] | |
Address = ${{ secrets.WG_DEVICE_ADDRESS }}/32 | |
PrivateKey = ${{ secrets.WG_DEVICE_PRIVATE_KEY }} | |
[Peer] | |
PublicKey = ${{ secrets.WG_SERVER_PUBLIC_KEY }} | |
Endpoint = ${{ secrets.WG_SERVER_PUBLIC_IP }}:51820 | |
AllowedIPs = ${{ secrets.WG_NETWORK }} | |
EOL" | |
- name: Start WireGuard interface | |
run: sudo systemctl start wg-quick@wg0 | |
- name: Upload processed audio to test device | |
env: | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
REMOTE_PASSWORD: ${{ secrets.REMOTE_PASSWORD }} | |
run: | | |
sudo apt-get install -y sshpass | |
sshpass -p $REMOTE_PASSWORD scp -o StrictHostKeyChecking=no "${{ github.workspace }}/processed-audio/audio.flac" [email protected]:/var/audio/fallback.flac |