97 lines
3.1 KiB
YAML
97 lines
3.1 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master # Change to your default branch if different
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: self-hosted # Ensure your self-hosted runner is configured
|
|
environment: 'prod'
|
|
steps:
|
|
- name: Get Current User
|
|
run: |
|
|
$env:USERNAME
|
|
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up .NET
|
|
uses: actions/setup-dotnet@v2
|
|
with:
|
|
dotnet-version: '9.0' # Change to your required .NET version
|
|
|
|
- name: Restore .NET Dependencies
|
|
run: dotnet restore ./HomeApi.sln
|
|
|
|
- name: Build .NET Project
|
|
run: dotnet build --configuration Release ./HomeApi/HomeApi.csproj
|
|
|
|
- name: Publish .NET Project
|
|
run: dotnet publish ./HomeApi/HomeApi.csproj --configuration Release --output ./output/dotnet
|
|
|
|
- name: Generate appsettings.json
|
|
run: |
|
|
$appSettings = @{
|
|
Logging = @{
|
|
LogLevel = @{
|
|
Default = "Information"
|
|
"Microsoft.AspNetCore" = "Warning"
|
|
}
|
|
}
|
|
ApiConfiguration = @{
|
|
EspConfiguration = @{
|
|
InformationBoardImageUrl = "${{ vars.ESP_IMAGE_URL }}"
|
|
UpdateIntervalMinutes = [int]"${{ vars.ESP_UPDATE_INTERVAL }}"
|
|
BlackTextThreshold = [int]"${{ vars.ESP_BLACK_TEXT_THRESHOLD }}"
|
|
EnableDithering = [System.Convert]::ToBoolean("${{ vars.ESP_ENABLE_DITHERING }}")
|
|
DitheringStrength = [int]"${{ vars.ESP_DITHERING_STRENGTH }}"
|
|
EnhanceContrast = [System.Convert]::ToBoolean("${{ vars.ESP_ENHANCE_CONTRAST }}")
|
|
ContrastStrength = [int]"${{ vars.ESP_CONTRAST_STRENGTH }}"
|
|
IsHighContrastMode = [System.Convert]::ToBoolean("${{ vars.ESP_HIGH_CONTRAST_MODE }}")
|
|
}
|
|
Keys = @{
|
|
Weather = "${{ secrets.WEATHER_API_KEY }}"
|
|
ResRobot = "${{ secrets.RES_ROBOT_API_KEY }}"
|
|
}
|
|
BaseUrls = @{
|
|
Nominatim = "${{ vars.NOMINATIM_URL }}"
|
|
Aurora = "${{ vars.AURORA_URL }}"
|
|
Weather = "${{ vars.WEATHER_URL }}"
|
|
ResRobot = "${{ vars.RES_ROBOT_URL }}"
|
|
}
|
|
DefaultCity = "${{ vars.DEFAULT_CITY }}"
|
|
DefaultStation = "${{ vars.DEFAULT_STATION }}"
|
|
}
|
|
AllowedHosts = "*"
|
|
}
|
|
|
|
$appSettings | ConvertTo-Json -Depth 10 | Set-Content -Path "./output/dotnet/appsettings.json"
|
|
Write-Host "Generated appsettings.json successfully"
|
|
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dotnet-artifacts
|
|
path: ./output/dotnet
|
|
|
|
deploy:
|
|
runs-on: self-hosted # Ensure your self-hosted runner is configured
|
|
needs: build
|
|
|
|
steps:
|
|
- name: Download .NET Artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dotnet-artifacts
|
|
path: ./output/dotnet
|
|
|
|
- name: Check Output Files
|
|
run: |
|
|
dir ./output/dotnet
|
|
|
|
- name: Copy .NET Publish Files to IIS Server
|
|
run: |
|
|
xcopy ".\output\dotnet\*" "C:\inetpub\applications\HomeApi" /s /i /y
|