Add CI/CD pipeline for Blazor WASM + API build & deploy
This commit is contained in:
parent
40585dcda9
commit
865a7da928
1 changed files with 62 additions and 0 deletions
62
.forgejo/workflows/build.yml
Normal file
62
.forgejo/workflows/build.yml
Normal file
|
|
@ -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"
|
||||
Loading…
Add table
Reference in a new issue