name: CI/CD on: push: branches: [main] pull_request: branches: [main] jobs: test-and-build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup 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 - name: Build static export run: npm run build - name: Upload build artifacts if: github.ref == 'refs/heads/main' && github.event_name == 'push' uses: actions/upload-pages-artifact@v3 with: path: out/ # Deploy to GitHub Pages (enable in repo Settings > Pages > Source: GitHub Actions) deploy: if: github.ref == 'refs/heads/main' && github.event_name == 'push' needs: test-and-build runs-on: ubuntu-latest permissions: pages: write id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4