56 lines
1.6 KiB
YAML
56 lines
1.6 KiB
YAML
name: Build & Test
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container: mcr.microsoft.com/dotnet/sdk:10.0
|
|
steps:
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --no-restore --configuration Release
|
|
|
|
- name: Test
|
|
run: dotnet test --no-build --configuration Release --verbosity normal
|
|
|
|
publish-client:
|
|
needs: build
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
container: mcr.microsoft.com/dotnet/sdk:10.0
|
|
steps:
|
|
- name: Publish Blazor WASM Client
|
|
run: dotnet publish src/CalorieTracker.Client -c Release -o /tmp/publish/client
|
|
|
|
- name: Deploy Client
|
|
run: |
|
|
echo "Deploying CalorieTracker WASM to /srv/web/calorie.holoshaii.dev/"
|
|
mkdir -p /srv/web/calorie.holoshaii.dev
|
|
cp -r /tmp/publish/client/wwwroot/* /srv/web/calorie.holoshaii.dev/
|
|
|
|
publish-api:
|
|
needs: build
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
container: mcr.microsoft.com/dotnet/sdk:10.0
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Publish API
|
|
run: dotnet publish src/CalorieTracker.Api -c Release -o /tmp/publish/api
|
|
|
|
- name: Deploy API
|
|
run: |
|
|
echo "Deploying CalorieTracker API..."
|
|
mkdir -p /opt/calorie-tracker
|
|
cp -r /tmp/publish/api/* /opt/calorie-tracker/
|
|
# Restart API service (if running as systemd)
|
|
sudo systemctl restart calorie-tracker || echo "API service not yet configured"
|