5.1 KiB
5.1 KiB
Deploy your Odoo PWA to GitHub Pages with GitHub Actions for continuous deployment.
What this command does:
- Sets up GitHub Actions workflow for automated deployment
- Configures GitHub Pages in repository settings
- Sets up repository secrets for environment variables
- Deploys the application to GitHub Pages
- Provides custom domain setup instructions
Prerequisites:
Before deploying, verify:
- ✅ Project builds successfully locally (
npm run build) - ✅ Git repository exists and is pushed to GitHub
- ✅ User has admin access to the repository
- ✅ GitHub Pages is enabled in repository settings
- ✅ Base URL configuration is correct for GitHub Pages
Important: GitHub Pages Limitations
⚠️ Note: GitHub Pages is static hosting only. Server-side API routes won't work.
Recommendation: For full Odoo PWA functionality with server-side API proxy:
- Use Vercel, Cloudflare Pages, or Netlify instead
- Or deploy API routes separately (e.g., Vercel Serverless Functions)
If Continuing with GitHub Pages:
You'll need to modify the Odoo client to use CORS-enabled direct Odoo API calls or deploy API routes separately.
Steps:
1. Configure GitHub Repository
# Ensure you're on main branch
git checkout main
git pull origin main
2. Set Up GitHub Actions Workflow
Check if .github/workflows/deploy.yml exists:
- If yes: Review and update if needed
- If no: Create the workflow file
3. Configure Repository Secrets
Go to: Repository → Settings → Secrets and variables → Actions
Add these secrets:
ODOO_API_KEY=your_production_api_key
ODOO_USERNAME=your.email@company.com
VITE_ODOO_URL=https://yourcompany.odoo.com
VITE_ODOO_DB=yourcompany-main
VITE_MODEL_NAME=x_expense
VITE_MODEL_DISPLAY_NAME=Expense
4. Enable GitHub Pages
Repository → Settings → Pages:
- Source: Deploy from a branch
- Branch:
gh-pages(will be created by Actions) - Folder:
/ (root)
5. Update Base Path
For framework-specific configuration:
SvelteKit (svelte.config.js):
paths: {
base: process.env.NODE_ENV === 'production' ? '/your-repo-name' : ''
}
React/Vue (vite.config.js):
base: process.env.NODE_ENV === 'production' ? '/your-repo-name/' : '/'
6. Commit and Push
git add .
git commit -m "Configure GitHub Pages deployment"
git push origin main
7. Monitor Deployment
- Go to Actions tab in GitHub
- Watch the deployment workflow
- Check for any errors
GitHub Actions Workflow
The workflow should:
- Trigger on push to
mainbranch - Install dependencies
- Build the project with environment variables
- Deploy to
gh-pagesbranch - GitHub Pages automatically serves from
gh-pages
Example Workflow (.github/workflows/deploy.yml):
name: Deploy to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install
- run: npm run build
env:
VITE_ODOO_URL: ${{ secrets.VITE_ODOO_URL }}
VITE_ODOO_DB: ${{ secrets.VITE_ODOO_DB }}
VITE_MODEL_NAME: ${{ secrets.VITE_MODEL_NAME }}
VITE_MODEL_DISPLAY_NAME: ${{ secrets.VITE_MODEL_DISPLAY_NAME }}
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
Custom Domain Setup (Optional):
- Add
CNAMEfile tostaticfolder with your domain - Configure DNS records:
- A record: Points to GitHub Pages IPs
- Or CNAME: Points to
username.github.io
- Enable HTTPS in repository settings (automatic)
Post-Deployment Checks:
After deployment, verify:
- ✅ Application loads at
https://username.github.io/repo-name - ✅ All assets load correctly (check browser console)
- ✅ Base path is correct for all routes
- ✅ Odoo connection works (may need CORS configuration)
- ✅ PWA installs correctly
Example prompts to use this command:
/deploy-github- Interactive GitHub Pages deployment- User: "Deploy to GitHub Pages"
- User: "Set up GitHub Actions for my PWA"
Troubleshooting:
Build Fails in Actions
- Check Actions logs for specific error
- Verify all secrets are set correctly
- Ensure Node version is compatible
- Test build locally first
404 on GitHub Pages
- Verify
gh-pagesbranch exists - Check GitHub Pages settings
- Ensure base path is configured
- Wait a few minutes for DNS propagation
Assets Not Loading
- Check base path configuration
- Verify all asset paths are relative
- Look for CORS issues in console
- Ensure service worker paths are correct
API Routes Don't Work
- GitHub Pages doesn't support server-side code
- Deploy API routes to Vercel/Netlify separately
- Or modify Odoo client for direct API calls with CORS
After Deployment:
Provide the user with:
- GitHub Pages URL
- Link to Actions tab for monitoring
- Instructions for custom domain setup
- Reminder about server-side limitations
- Alternative hosting recommendations if needed