This guide explains exactly how to configure GitHub Pages to work with the GitHub Actions deployment workflow.
Before setting up GitHub Pages:
- β Repository must be public (or you need GitHub Pro for private repos)
- β
.github/workflows/deploy.ymlfile exists in your repository - β
Code is pushed to the
mainbranch - β First workflow run has completed successfully
-
Go to your GitHub repository
-
Click the "Settings" tab (βοΈ icon)
https://github.com/YOUR_USERNAME/YOUR_REPO/settings
-
In the left sidebar, scroll down to "Code and automation" section
-
Click "Pages"
Settings β Pages
This is the most important step:
-
Under "Build and deployment"
-
Find the "Source" dropdown
-
Select "GitHub Actions" (NOT "Deploy from a branch")
Source: GitHub Actions β Select this optionWhy GitHub Actions?
- Allows custom build processes
- Works with TypeScript/Vite build
- Automated deployment on push
- Full control over build steps
- GitHub will automatically save when you select "GitHub Actions"
- You'll see a message: "GitHub Pages is currently being built from GitHub Actions"
- Still in Settings, go to "Actions" β "General"
- Scroll to "Workflow permissions"
- Ensure the following is selected:
- β "Read and write permissions"
- β "Allow GitHub Actions to create and approve pull requests" (optional but recommended)
- Click "Save"
# Make any change (even a small one)
echo "# Deploy test" >> README.md
# Commit and push
git add .
git commit -m "Trigger GitHub Pages deployment"
git push origin main- Go to the "Actions" tab in your repository
- Click on "Deploy to GitHub Pages" workflow (left sidebar)
- Click "Run workflow" button (right side)
- Select "main" branch
- Click green "Run workflow" button
- Go to "Actions" tab
- Click on the latest workflow run
- Watch the progress:
- Build job: TypeScript compilation, Vite build
- Deploy job: Upload to GitHub Pages
βββββββββββββββββββ
β Build Job β ~2-3 minutes
β - Checkout β
β - Install deps β
β - Type check β
β - Build β
β - Upload β
βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Deploy Job β ~30 seconds
β - Deploy Pages β
βββββββββββββββββββ
β
βΌ
β
Success!
If something fails:
- Click on the failed workflow run
- Click on "build" or "deploy" job
- Expand the failed step
- Read error messages
- Fix issues and push again
Once deployment succeeds, your site will be available at:
https://YOUR_USERNAME.github.io/YOUR_REPO_NAME/
Example:
- Username:
SolidRhino - Repo:
automaticinstall-GUI-Ubuntu - URL:
https://solidrhino.github.io/automaticinstall-GUI-Ubuntu/
- Go to Settings β Pages
- At the top, you'll see:
Your site is live at https://YOUR_USERNAME.github.io/YOUR_REPO_NAME/ - Click the link to visit your site
If you have a custom domain:
- In Settings β Pages
- Under "Custom domain"
- Enter your domain:
example.com - Click "Save"
- Configure DNS records with your domain provider
Critical: The base path must match your repository name.
Current configuration (in vite.config.ts):
base: process.env.GITHUB_PAGES ? '/automaticinstall-GUI-Ubuntu/' : '/',If your repo name is different:
base: process.env.GITHUB_PAGES ? '/YOUR_REPO_NAME/' : '/',
// ^^^^^^^^^^^^^^^^
// Must match your repo name exactly!For custom domain or username.github.io repos:
base: '/',{
"homepage": "https://YOUR_USERNAME.github.io/YOUR_REPO_NAME"
}Cause: Repository settings may not have Actions enabled.
Solution:
- Go to Settings β Actions β General
- Under "Actions permissions", ensure Actions are enabled
- Go back to Settings β Pages
- "GitHub Actions" should now appear
Possible Causes & Solutions:
Check: vite.config.ts base path
// β Wrong
base: '/' // For GitHub Pages with repo, this won't work
// β
Correct
base: process.env.GITHUB_PAGES ? '/automaticinstall-GUI-Ubuntu/' : '/'Fix: Update base path and redeploy
Check: Settings β Pages β Source
Source must be: GitHub Actions (not "Deploy from a branch")
Fix: Change source to "GitHub Actions"
Check: Build output in workflow logs
# Should see:
dist/
βββ index.html β Must exist
βββ assets/
βββ ...Fix: Ensure vite build generates index.html
Symptom: Page loads but no styling/functionality
Cause: Incorrect asset paths
Solution:
- Open browser DevTools (F12)
- Check Console for 404 errors
- Verify asset URLs match base path
- Update
vite.config.tsbase path - Rebuild and redeploy
Error Message:
Error: Resource not accessible by integration
Cause: Insufficient workflow permissions
Solution:
- Settings β Actions β General
- Workflow permissions
- Select "Read and write permissions"
- Save
- Re-run workflow
Possible Causes:
Local: You might use Node 18 GitHub: Workflow uses Node 20
Solution: Test locally with Node 20
nvm install 20
nvm use 20
npm run buildCause: Dependencies in devDependencies but needed in production
Solution: Move to dependencies if needed
npm install --save package-nameCause: Strict type checking in CI
Solution: Run type check locally
npm run type-checkAdd a status badge to your README:
[](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/deploy.yml)Shows:
- β Green: Last deployment succeeded
- β Red: Last deployment failed
- π‘ Yellow: Deployment in progress
1. Developer pushes to main branch
β
2. GitHub Actions detects push
β
3. Workflow starts automatically
β
4. Build job runs (install, type-check, build)
β
5. Build artifact uploaded
β
6. Deploy job runs (downloads artifact)
β
7. Pages deployment completes
β
8. Site live at github.io URL
β
9. CloudFlare CDN distributes globally (~30s)
β
10. β
Users see updated site
- Workflow start: ~10 seconds after push
- Build job: ~2-3 minutes
- Deploy job: ~30 seconds
- CDN propagation: ~30 seconds
- Total: ~3-4 minutes from push to live
# Always test locally before pushing to main
npm run type-check # Check for TypeScript errors
npm run build # Ensure build succeeds
npm run preview # Test the build output- Settings β Branches
- Add rule for
main - Require status checks:
- β Build must pass
- β Type check must pass
- Subscribe to workflow notifications
- Check status badge regularly
- Review failed deployments promptly
# Check for updates monthly
npm outdated
# Update dependencies
npm update
# Test after updates
npm run buildBefore considering setup complete:
- Repository Settings β Pages β Source = "GitHub Actions"
- Workflow permissions = "Read and write permissions"
-
vite.config.tsbase path matches repo name - First workflow run completed successfully
- Site accessible at
github.ioURL - All pages load correctly (no 404s)
- CSS and JavaScript working
- Dark mode functioning
- PWA installable
- Mobile responsive
You know everything is working when:
- β Actions tab shows green checkmarks
- β Settings β Pages shows "Your site is live at..."
- β Visiting the URL shows your app
- β Future pushes to main auto-deploy
- β Status badge in README shows passing
Need Help?
If you encounter issues not covered here:
- Check GitHub Actions logs
- Review browser console (F12)
- Verify all configuration files
- Test build locally
- Check GitHub Pages status page
Last Updated: Created during TypeScript migration