Repository navigation
appease eslint #16
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ master, main, develop ] | |
| pull_request: | |
| branches: [ master, main ] | |
| env: | |
| DOTNET_VERSION: '10.0.x' | |
| NODE_VERSION: '20.x' | |
| 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: ${{ env.DOTNET_VERSION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Restore .NET dependencies | |
| run: dotnet restore | |
| - name: Install npm dependencies | |
| run: npm ci | |
| - name: Run backend tests | |
| run: | | |
| if [ -d "csgoSkinStatistics.Tests" ]; then | |
| dotnet test csgoSkinStatistics.Tests --no-restore --verbosity normal --logger trx --results-directory TestResults --collect:"XPlat Code Coverage" | |
| else | |
| echo "No backend tests found" | |
| fi | |
| - name: Run frontend tests | |
| run: npm test -- --watchAll=false | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Build application | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: TestResults/ | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@v0.36.0 | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| - name: Upload Trivy scan results to GitHub Security tab | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| build-and-package: | |
| runs-on: ubuntu-latest | |
| needs: [test, security-scan] | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| dotnet restore | |
| npm ci | |
| - name: Publish application | |
| run: dotnet publish --configuration Release --output ./publish | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: published-app | |
| path: ./publish/ |