Skip to content

Commit 2dd9c19

Browse files
author
martinmeerAT
committed
Add GitHub Pages deployment workflow for both apps
- Deploy marketing-site to root (/) - Deploy main-app to /app/ subdirectory - Build both apps and combine into single GitHub Pages deployment - Add comprehensive deployment documentation - Workflow runs on push to main branch or manually via workflow_dispatch
1 parent 2d1b8ce commit 2dd9c19

File tree

2 files changed

+192
-0
lines changed

2 files changed

+192
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
# Sets permissions for GitHub Pages deployment
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
# Allow only one concurrent deployment
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build-and-deploy:
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
# Build Marketing Site
31+
- name: Setup Node.js for Marketing Site
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '18'
35+
cache: 'npm'
36+
cache-dependency-path: apps/marketing-site/package-lock.json
37+
38+
- name: Install Marketing Site dependencies
39+
working-directory: apps/marketing-site
40+
run: npm ci
41+
42+
- name: Build Marketing Site
43+
working-directory: apps/marketing-site
44+
run: npm run build
45+
46+
# Build Main App
47+
- name: Install Main App dependencies
48+
working-directory: apps/main-app
49+
run: npm ci
50+
51+
- name: Build Main App
52+
working-directory: apps/main-app
53+
run: npm run build
54+
55+
# Prepare deployment directory
56+
- name: Prepare GitHub Pages content
57+
run: |
58+
mkdir -p _site
59+
# Copy marketing site to root
60+
cp -r apps/marketing-site/dist/* _site/
61+
# Copy main app to /app subdirectory
62+
mkdir -p _site/app
63+
cp -r apps/main-app/dist/* _site/app/
64+
# Copy shared assets if needed
65+
if [ -d "packages/shared/img" ]; then
66+
mkdir -p _site/shared/img
67+
cp -r packages/shared/img/* _site/shared/img/
68+
fi
69+
# Ensure .nojekyll exists
70+
touch _site/.nojekyll
71+
echo "Deployment structure:"
72+
ls -la _site/
73+
echo "Main app content:"
74+
ls -la _site/app/ || echo "No app directory"
75+
76+
- name: Setup Pages
77+
uses: actions/configure-pages@v5
78+
79+
- name: Upload artifact
80+
uses: actions/upload-pages-artifact@v3
81+
with:
82+
path: './_site'
83+
84+
- name: Deploy to GitHub Pages
85+
id: deployment
86+
uses: actions/deploy-pages@v4
87+

GITHUB_PAGES_DEPLOYMENT.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# GitHub Pages Deployment Guide
2+
3+
## Deployment Structure
4+
5+
This monorepo deploys both applications to GitHub Pages:
6+
7+
```
8+
https://your-username.github.io/your-repo/
9+
├── / → Marketing Site (apps/marketing-site)
10+
└── /app/ → Main Application (apps/main-app)
11+
```
12+
13+
## URLs
14+
15+
- **Marketing Site**: `https://your-username.github.io/your-repo/`
16+
- **Main Application**: `https://your-username.github.io/your-repo/app/`
17+
18+
## Setup Instructions
19+
20+
### 1. Enable GitHub Pages
21+
22+
1. Go to your repository on GitHub
23+
2. Navigate to **Settings****Pages**
24+
3. Under "Build and deployment":
25+
- **Source**: Select **"GitHub Actions"** (not "Deploy from a branch")
26+
- This is crucial - it prevents automatic Jekyll builds
27+
28+
### 2. Deploy
29+
30+
The deployment happens automatically when you push to the `main` branch:
31+
32+
```bash
33+
git push origin main
34+
```
35+
36+
### 3. Manual Deployment
37+
38+
You can also trigger a deployment manually:
39+
1. Go to **Actions** tab on GitHub
40+
2. Select **"Deploy to GitHub Pages"** workflow
41+
3. Click **"Run workflow"**
42+
43+
## How It Works
44+
45+
1. **Build Phase**:
46+
- Marketing site is built (`apps/marketing-site → dist/`)
47+
- Main app is built (`apps/main-app → dist/`)
48+
49+
2. **Deployment Phase**:
50+
- Marketing site deployed to root (`/`)
51+
- Main app deployed to `/app/` subdirectory
52+
- Shared assets copied to `/shared/`
53+
- `.nojekyll` file added to skip Jekyll processing
54+
55+
## Local Testing
56+
57+
### Marketing Site
58+
```bash
59+
cd apps/marketing-site
60+
npm run dev
61+
```
62+
63+
### Main App
64+
```bash
65+
cd apps/main-app
66+
npm run dev
67+
```
68+
69+
## Troubleshooting
70+
71+
### Jekyll Errors
72+
73+
If you see Jekyll-related errors like:
74+
```
75+
Error: No such file or directory @ rb_check_realpath_internal
76+
```
77+
78+
**Solution**: Ensure GitHub Pages is set to **"GitHub Actions"** mode (not "Deploy from a branch").
79+
80+
### 404 Errors
81+
82+
If pages show 404:
83+
1. Check that the workflow completed successfully in the **Actions** tab
84+
2. Verify the build outputs exist in the workflow logs
85+
3. Ensure paths in your HTML/JS match the deployment structure
86+
87+
### Asset Loading Issues
88+
89+
If assets don't load in the deployed app:
90+
- Marketing site assets should use root-relative paths: `/assets/...`
91+
- Main app assets should use: `/app/assets/...`
92+
93+
## CI/CD Workflows
94+
95+
- **`deploy-github-pages.yml`**: Deploys to GitHub Pages (runs on `main` branch)
96+
- **`main-app-ci.yml`**: CI for main app (build, test, Docker)
97+
- **`marketing-site-ci.yml`**: CI for marketing site (build, test, Docker)
98+
99+
## Notes
100+
101+
- The `.nojekyll` file disables Jekyll processing
102+
- `_config.yml` and `.jekyllignore` are kept as fallbacks
103+
- Both apps maintain independent build processes
104+
- Docker deployments remain separate from GitHub Pages
105+

0 commit comments

Comments
 (0)