name: Deploy to Production on: push: branches: [main] workflow_dispatch: jobs: deploy: name: Deploy to Netlify/Vercel runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20.x' cache: 'npm' - name: Install dependencies run: npm ci - name: Run tests run: npm run test:run - name: Build for production run: npm run build:prod env: VITE_BACKEND_API_URL: ${{ secrets.VITE_BACKEND_API_URL_PROD }} VITE_ENV: production VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }} # Option 1: Deploy to Netlify - name: Deploy to Netlify uses: nwtgck/actions-netlify@v3.0 with: publish-dir: './dist' production-branch: main github-token: ${{ secrets.GITHUB_TOKEN }} deploy-message: "Deploy from GitHub Actions" enable-pull-request-comment: true enable-commit-comment: true env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} timeout-minutes: 5 # Option 2: Deploy to Vercel (comment out Netlify if using this) # - name: Deploy to Vercel # uses: amondnet/vercel-action@v25 # with: # vercel-token: ${{ secrets.VERCEL_TOKEN }} # vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} # vercel-args: '--prod' # working-directory: ./ - name: Notify deployment success if: success() run: echo "Deployment successful!" - name: Notify deployment failure if: failure() run: echo "Deployment failed!"