This guide explains how to deploy the Storybook and test coverage reports to GitHub Pages.
The project deploys two main resources to GitHub Pages:
- Storybook - Interactive component demos at
/storybook/ - Test Coverage - Coverage reports at
/coverage/ - Landing Page - Main page with links to both at
/
The GitHub Actions workflow automatically deploys on every push to main:
-
Enable GitHub Pages in your repository settings:
- Go to Settings > Pages
- Source: "GitHub Actions"
- This will use the workflow in
.github/workflows/deploy-pages.yml
-
Push to main branch:
git push origin main
-
Wait for deployment (2-3 minutes):
- Check Actions tab for deployment status
- Once complete, site will be live
After deployment, your sites will be available at:
- Landing Page:
https://crashbytes.github.io/react-version-compare/ - Storybook:
https://crashbytes.github.io/react-version-compare/storybook/ - Coverage:
https://crashbytes.github.io/react-version-compare/coverage/
If you prefer to deploy manually:
# Run tests, build storybook, and deploy
npm run deploy:allThis single command:
- Runs tests with coverage
- Builds Storybook
- Combines both into deployment directory
- Deploys to GitHub Pages
Deploy only Storybook:
npm run storybook:deployDeploy only coverage:
npm run coverage:deploy# 1. Run tests with coverage
npm run test:coverage
# 2. Build Storybook
npm run build-storybook
# 3. Deploy combined
npm run deploy:combinedBefore deploying, preview locally:
npm run storybook
# Opens at http://localhost:6006npm run coverage:report
# Generates report and opens in browsergh-pages branch
├── index.html # Landing page
├── .nojekyll # Bypass Jekyll processing
├── storybook/
│ └── index.html # Storybook entry point
│ └── ... # Storybook assets
└── coverage/
└── index.html # Coverage report entry
└── ... # Coverage assets
Check GitHub Actions permissions:
- Settings > Actions > General
- Workflow permissions: "Read and write permissions"
- Allow GitHub Actions to create and approve pull requests: ✓
Check Pages settings:
- Settings > Pages
- Source: "GitHub Actions" (not "Deploy from branch")
Clear GitHub Pages cache:
- Make a small change to any file
- Push to main
- Wait for new deployment
Check .nojekyll file:
- Ensure
.nojekyllexists in gh-pages root - This prevents Jekyll from processing paths with underscores
Check build output:
npm run build-storybook
# Verify storybook-static directory is createdCheck for errors:
- Look at GitHub Actions logs
- Check browser console for errors
Verify coverage generation:
npm run test:coverage
# Check coverage/lcov-report/index.html existsClear old coverage:
rm -rf coverage
npm run test:coverageThe workflow (.github/workflows/deploy-pages.yml) runs on:
- Every push to
mainbranch - Manual trigger (workflow_dispatch)
Steps:
- Checkout code
- Setup Node.js 18
- Install dependencies (
npm ci) - Run tests with coverage
- Build Storybook
- Create deployment directory structure
- Generate landing page
- Deploy to GitHub Pages
| Script | Description |
|---|---|
npm run storybook |
Start Storybook dev server (port 6006) |
npm run build-storybook |
Build Storybook for production |
npm run storybook:deploy |
Build and deploy Storybook only |
npm run test:coverage |
Run tests with coverage |
npm run coverage:report |
Generate and open coverage report |
npm run coverage:deploy |
Deploy coverage report only |
npm run deploy:all |
Run tests, build storybook, deploy combined |
npm run deploy:combined |
Deploy pre-built assets (uses script) |
To use a custom domain:
-
Add CNAME file to deployment:
echo "your-domain.com" > gh-pages-deploy/CNAME
-
Configure DNS:
- Add CNAME record:
your-subdomain→crashbytes.github.io - Or A records for apex domain (see GitHub docs)
- Add CNAME record:
-
Update repository settings:
- Settings > Pages > Custom domain
- Enter your domain
- Enable "Enforce HTTPS"
The workflow ensures:
- ✅ Automated deployment on every push
- ✅ Tests must pass before deployment
- ✅ Consistent coverage metrics
- ✅ Always up-to-date Storybook
- ✅ No manual intervention needed
Check deployment status:
- GitHub Actions tab shows workflow runs
- Green checkmark = successful deployment
- Red X = deployment failed (check logs)
Verify live sites:
- Landing page loads and shows correct stats
- Storybook loads and components work
- Coverage report displays correct metrics
-
Always run tests locally first:
npm test npm run test:coverage -
Preview Storybook before deploying:
npm run storybook
-
Use automated deployment for consistency
-
Check Actions tab after pushing to main
-
Update stats in landing page if metrics change significantly
The landing page is auto-generated with hardcoded stats. To update:
Option 1: Update GitHub Actions workflow
Edit .github/workflows/deploy-pages.yml and modify the stats in the HTML.
Option 2: Update deployment script
Edit scripts/deploy-gh-pages.js and modify the landingPage template.
- No sensitive data in coverage reports
- All tests run in CI before deployment
- Public access to Storybook and coverage
- No authentication required
If deployment issues persist:
- Check GitHub Status page
- Review Actions logs for errors
- Verify repository permissions
- Check gh-pages branch exists
# Full deployment workflow
npm run test:coverage # Generate coverage
npm run build-storybook # Build Storybook
npm run deploy:combined # Deploy both
# Or use single command
npm run deploy:all # Does all above stepsURLs after deployment: