Css fix #8
Workflow file for this run
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: | |
| - main | |
| - feature/* | |
| pull_request: # Runs tests on PRs | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Cache node_modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm # Cache npm instead of node_modules for better reliability | |
| key: node-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
| restore-keys: | | |
| node-cache-${{ runner.os }}- | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run Tests | |
| run: npm test -- --coverage | |
| - name: Upload Coverage Report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: ./coverage/lcov-report/ | |
| build_docker: | |
| needs: test # Only build Docker if tests pass | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: snarelord | |
| password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
| - name: Build and Push Docker Image | |
| run: | | |
| docker build -t snarelord/blackjack:${{ github.sha }} . | |
| docker push snarelord/blackjack:${{ github.sha }} | |
| deploy: | |
| needs: build_docker # Deploy only after Docker image is built | |
| if: github.event_name == 'push' # Prevent deployment on PRs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Install Vercel CLI | |
| run: npm install -g vercel@latest | |
| - name: Pull Vercel Environment | |
| run: vercel pull --yes --token ${{ secrets.VERCEL_TOKEN }} | |
| - name: Set Sentry DSN | |
| run: echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> $GITHUB_ENV | |
| - name: Set Sentry Auth Token | |
| run: echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> $GITHUB_ENV | |
| - name: Build Project | |
| run: vercel build --prod --token ${{ secrets.VERCEL_TOKEN }} | |
| - name: Deploy Project | |
| run: vercel deploy --prod --token ${{ secrets.VERCEL_TOKEN }} |