This document outlines the GitHub Pages deployment process for the trauma-informed UI project, which can be refactored and reused for other projects.
The deployment uses a combination of GitHub Actions, Vite build system, and the gh-pages package to automatically deploy static files to GitHub Pages.
Live Site: https://github.com/Festa-Design-Studio/trauma-informed-ui
Location: .github/workflows/deploy.yml
The workflow typically includes:
- Trigger: Pushes to main branch
- Build Process: Uses Vite to generate static files
- Deploy: Pushes built files to
gh-pagesbranch
Key deployment scripts:
{
"scripts": {
"build": "npm run build:icons && vite build",
"build:icons": "node scripts/generateSprite.js",
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
},
"devDependencies": {
"gh-pages": "^x.x.x"
}
}Location: vite.config.js
Critical requirement: All HTML files must be explicitly listed
export default defineConfig({
build: {
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
typography: resolve(__dirname, "src/components/atoms/typography.html"),
buttons: resolve(__dirname, "src/components/atoms/buttons.html"),
// Add each new HTML file here
}
}
}
});Implemented: June 2024
- Static-First: All dynamic includes are inlined at build time
- Explicit File Management: Every HTML file must be declared in Vite config
- Build Validation: All components tested in static build before completion
- Navigation Integrity: Links point only to files that exist in build output
- Reliability: Eliminates runtime 404 errors
- Performance: Faster loading with pre-built static files
- Compatibility: Works with any static hosting service
- Maintenance: Clear dependency tracking
- Push to Main Branch
- GitHub Actions Triggers
- Build Process Runs:
- Generate icon sprites
- Build static files with Vite
- Output to
distfolder
- Deploy to GitHub Pages
- Site Updates Live
# Build the project
npm run build
# Deploy to GitHub Pages
npm run deploynpm run build:icons- Script:
scripts/generateSprite.js - Purpose: Creates SVG sprite for trauma-informed icons
- Output: Optimized icon assets
vite build- Input: Source files and components
- Processing: Inlines includes, optimizes assets
- Output: Static files in
distfolder
- Images processed and optimized
- CSS bundled and minified
- JavaScript modules compiled
- HTML files generated for each component
Cause: HTML file not included in vite.config.js
Solution: Add missing file to rollupOptions.input
input: {
// ...existing files...
newPage: resolve(__dirname, "src/components/path/new-page.html")
}Cause: Links pointing to files not in build output
Solution: Ensure all linked HTML files are:
- Added to Vite config
- Present in
distafter build - Using correct relative paths
Cause: Incorrect path configuration for GitHub Pages subdirectory
Solution: Configure base path in Vite config:
export default defineConfig({
base: '/repository-name/',
// ...other config
});-
Copy Workflow Structure
.github/workflows/deploy.yml- Adapt repository-specific settings
-
Setup Package Scripts
- Install
gh-pagesdependency - Configure build and deploy scripts
- Install
-
Configure Build Tool
- Setup Vite or similar static site generator
- Implement explicit file input system
-
Implement Static Build Policy
- Replace dynamic includes with build-time generation
- Add validation for all HTML files
-
Setup Asset Pipeline
- Configure icon/image processing
- Optimize for static deployment
-
Documentation
- Create troubleshooting guide
- Document file addition process
{
"devDependencies": {
"vite": "^x.x.x",
"gh-pages": "^x.x.x"
}
}project/
├── .github/workflows/
│ └── deploy.yml
├── src/
│ └── components/
├── scripts/
│ └── generateSprite.js
├── dist/ (generated)
├── vite.config.js
├── package.json
└── DEVELOPMENT_RULES.md
- Test Locally: Always test build output before deploying
- Validate Links: Ensure all navigation works in static build
- Monitor Builds: Watch GitHub Actions for deployment status
- Document Changes: Update file lists when adding new pages
- Backup Strategy: Keep build configuration in version control
- Regular Updates: Keep dependencies current
- Build Monitoring: Check deployment logs for errors
- Performance Review: Monitor site speed and optimization
- Documentation Updates: Keep setup instructions current
This deployment setup prioritizes reliability and maintainability, making it ideal for documentation sites and design systems that require consistent availability.