diff --git a/.gitea/workflows/build-pr.yaml b/.gitea/workflows/build-pr.yaml index abfb2f3..c26acc3 100644 --- a/.gitea/workflows/build-pr.yaml +++ b/.gitea/workflows/build-pr.yaml @@ -1,25 +1,31 @@ name: Game Ideas build for PR on: - pull_request: - types: [ opened, edited, reopened, synchronize ] - branches: - - 'feature/**' - - main + pull_request: + types: [ opened, edited, reopened, synchronize ] + branches: + - 'feature/**' + - main jobs: - build_blazor_app: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v4 + build_blazor_app: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Setup DotNet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9' + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' - - name: Build Blazor App - run: dotnet build ./src/GameIdeas/Client/GameIdeas.BlazorApp/GameIdeas.BlazorApp.csproj - - - name: Build API App - run: dotnet build ./src/GameIdeas/Server/GameIdeas.WebAPI/GameIdeas.WebAPI.csproj \ No newline at end of file + - name: Restore dependencies + run: dotnet restore + + - name: Build API + run: dotnet build ./src/GameIdeas/Server/GameIdeas.WebAPI/GameIdeas.WebAPI.csproj --configuration Release + + - name: Build Blazor App + run: dotnet build ./src/GameIdeas/Client/GameIdeas.BlazorApp/GameIdeas.BlazorApp.csproj --configuration Release + + - name: Test API + run: dotnet test ./src/GameIdeas/Server/GameIdeas.WebAPI.Tests/GameIdeas.WebAPI.Tests.csproj --configuration Release \ No newline at end of file diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..097d530 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,92 @@ +name: Game Ideas deploy + +on: + push: + branches: [main] # Déclenchement sur push sur main + workflow_dispatch: # Lancer manuellement + +jobs: + build-test-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build API + run: dotnet build ./src/GameIdeas/Server/GameIdeas.WebAPI/GameIdeas.WebAPI.csproj --configuration Release + + - name: Build Blazor App + run: dotnet build ./src/GameIdeas/Client/GameIdeas.BlazorApp/GameIdeas.BlazorApp.csproj --configuration Release + + - name: Test API + run: dotnet test ./src/GameIdeas/Server/GameIdeas.WebAPI.Tests/GameIdeas.WebAPI.Tests.csproj --configuration Release + + - name: Publish API + run: dotnet publish ./src/GameIdeas/Server/GameIdeas.WebAPI/GameIdeas.WebAPI.csproj --configuration Release --output ./publish/api + + - name: Publish Blazor App + run: dotnet publish ./src/GameIdeas/Client/GameIdeas.BlazorApp/GameIdeas.BlazorApp.csproj --configuration Release --output ./publish/blazor + + - name: Copy API to Server + uses: appleboy/scp-action@v1 + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + password: ${{ secrets.DEV_PASSWORD }} + port: ${{ secrets.DEV_PORT }} + source: "./publish/api/*" + target: "/home/gameideas/api" + + - name: Copy Blazor App to Server + uses: appleboy/scp-action@v1 + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + password: ${{ secrets.DEV_PASSWORD }} + port: ${{ secrets.DEV_PORT }} + source: "./publish/blazor/*" + target: "/home/gameideas/blazor" + + - name: Update Entity Framework API on server + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + password: ${{ secrets.DEV_PASSWORD }} + port: ${{ secrets.DEV_PORT }} + script: | + cd /home/gameideas/api + dotnet ef database update --no-build + + - name: Start API on server + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + password: ${{ secrets.DEV_PASSWORD }} + port: ${{ secrets.DEV_PORT }} + script: | + pkill -f "GameIdeas.WebAPI" || true + cd /home/gameideas/api + nohup dotnet GameIdeas.WebAPI.dll > api.log 2>&1 & + + - name: Start Blazor App on server + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + password: ${{ secrets.DEV_PASSWORD }} + port: ${{ secrets.DEV_PORT }} + script: | + pkill -f "GameIdeas.BlazorApp" || true + cd /home/gameideas/blazor + nohup dotnet GameIdeas.BlazorApp.dll > blazor.log 2>&1 & \ No newline at end of file