React CI/CD Pipeline
Set up continuous integration and deployment for React apps.
Automate testing and deployment.
GitHub Actions
```.github/workflows/deploy.yml name: Deploy
on: push: branches: [main]
jobs: build-and-deploy: runs-on: ubuntu-latest
steps: - uses: actions/checkout@v2
- name: Setup Node uses: actions/setup-node@v2 with: node-version: '18'
- name: Install dependencies run: npm ci
- name: Run tests run: npm test
- name: Build run: npm run build
- name: Deploy run: npm run deploy ```
Pre-commit Hooks
Install Husky: ```bash npm install --save-dev husky lint-staged npx husky install ```
```json { "lint-staged": { "*.{js,jsx}": ["eslint --fix", "prettier --write"] } } ```
Automated Testing
Run tests before deploy: ```bash npm test -- --coverage --watchAll=false ```
Environment-based Builds
```bash npm run build:dev npm run build:staging npm run build:prod ```
Remember
- Automate everything - Run tests in CI - Use environment variables - Deploy automatically - Monitor deployments
> Congratulations! You've mastered React from beginner to advanced! Keep building amazing apps!