fix FE #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Backend CI/CD | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'VehicleShowroomManagement/**' | |
| - 'Dockerfile' | |
| - 'docker-compose.yml' | |
| - '.github/workflows/backend-ci.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'VehicleShowroomManagement/**' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore dependencies | |
| working-directory: ./VehicleShowroomManagement | |
| run: dotnet restore | |
| - name: Build solution | |
| working-directory: ./VehicleShowroomManagement | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Run tests | |
| working-directory: ./VehicleShowroomManagement | |
| run: dotnet test --no-build --configuration Release --verbosity normal | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: false | |
| tags: vehicleshowroom-api:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Test Docker image | |
| run: | | |
| docker run --rm -d -p 8080:10000 --name test-container vehicleshowroom-api:latest | |
| sleep 10 | |
| curl -f http://localhost:8080/health || exit 1 | |
| docker stop test-container | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build-docker | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Deploy to Render | |
| uses: johnbeynon/[email protected] | |
| with: | |
| service-id: ${{ secrets.RENDER_BACKEND_SERVICE_ID }} | |
| api-key: ${{ secrets.RENDER_API_KEY }} |