A React application with automated CI/CD pipeline using GitHub Actions.
✅ Continuous Integration
- Automated builds on push and pull requests
- Multi-version Node.js testing (16.x, 18.x)
- Automated testing and linting
✅ Code Quality
- Security vulnerability scanning
- Code quality checks
- SonarQube integration (optional)
✅ Continuous Deployment
- Automated deployment to GitHub Pages
- Slack notifications
- Production build optimization
├── .github/
│ └── workflows/ # GitHub Actions workflows
│ ├── ci-cd.yml # Main CI/CD pipeline
│ ├── code-quality.yml # Code quality checks
│ └── deploy.yml # Production deployment
├── public/
│ └── index.html # HTML template
├── src/
│ ├── App.js # Main React component
│ ├── App.css # App styles
│ ├── App.test.js # App tests
│ ├── index.js # App entry point
│ ├── index.css # Global styles
│ └── reportWebVitals.js # Performance monitoring
├── package.json # Project dependencies
├── .gitignore # Git ignore rules
└── README.md # This file
- Node.js (v16.x or higher)
- npm or yarn
- Git
- Clone the repository
git clone https://github.com/yourusername/react-cicd-project.git
cd react-cicd-project- Install dependencies
npm install- Start development server
npm startOpen http://localhost:3000 to view it in the browser.
- Run tests
npm test- Build for production
npm run build- Trigger: Push to
main/develop, Pull Requests - Jobs:
- Install dependencies
- Run tests
- Build project
- Upload artifacts
- Optional SonarQube scan
- Trigger: Push to
main/develop, Pull Requests - Jobs:
- Code linting
- Security audit
- Coverage reports
- Trigger: Push to
main, Manual trigger - Jobs:
- Build project
- Deploy to GitHub Pages
- Slack notification
Create a .env.local file for local development:
REACT_APP_API_URL=http://localhost:3000
Add these secrets to your GitHub repository for CI/CD:
SONAR_HOST_URL # SonarQube host URL
SONAR_TOKEN # SonarQube token
SLACK_WEBHOOK_URL # Slack webhook for notifications
To add secrets:
- Go to Repository Settings → Secrets and variables → Actions
- Click "New repository secret"
- Add each secret with its value
The project automatically deploys to GitHub Pages when changes are pushed to the main branch.
To enable GitHub Pages:
- Go to Repository Settings → Pages
- Set Source to "Deploy from a branch"
- Select
gh-pagesbranch - Update the
cnamein.github/workflows/deploy.ymlwith your custom domain (optional)
| Command | Description |
|---|---|
npm start |
Run development server |
npm test |
Run test suite |
npm run build |
Build production bundle |
npm run eject |
Eject from Create React App (irreversible) |
npm run lint |
Run linter (if configured) |
- Clear node_modules:
rm -rf node_modules && npm install - Update npm:
npm install -g npm@latest
- Check Node.js version:
node --version - Ensure all dependencies are installed:
npm ci
- Verify GitHub Pages is enabled in Settings
- Check workflow logs: Actions tab → Recent workflow runs
- Ensure
GITHUB_TOKENsecret is properly configured
✅ Automated Testing - Every commit is tested automatically ✅ Code Quality - Standards enforced before merge ✅ Consistent Builds - Same environment for all developers ✅ Faster Feedback - Developers know issues immediately ✅ Automatic Deployment - Less manual work in production
- Branch Protection - Require status checks to pass before merging
- Code Review - Use pull requests for all changes
- Commit Messages - Use meaningful commit messages
- Testing - Write tests for new features
- Documentation - Keep README updated
MIT
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Happy coding! 🚀