diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..4483b7c --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,62 @@ +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: Checkout + uses: actions/checkout@v4 + + - 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: Checkout + uses: actions/checkout@v4 + + - 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"