Skip to content

Commit 2f2e577

Browse files
committed
ci: add github pages
1 parent 2ea0451 commit 2f2e577

File tree

5 files changed

+179
-0
lines changed

5 files changed

+179
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
# Runs on pushes targeting the main branch
5+
push:
6+
branches: ["main"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 9.0.0
35+
36+
- name: Setup Node
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: "20"
40+
cache: "pnpm"
41+
42+
- name: Setup Pages
43+
uses: actions/configure-pages@v5
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
48+
- name: Build
49+
run: pnpm run build
50+
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: ./dist
55+
56+
# Deployment job
57+
deploy:
58+
environment:
59+
name: github-pages
60+
url: ${{ steps.deployment.outputs.page_url }}
61+
runs-on: ubuntu-latest
62+
needs: build
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

DEPLOYMENT.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# GitHub Pages Deployment Setup
2+
3+
## What Was Added
4+
5+
### 1. GitHub Actions Workflow (`.github/workflows/deploy.yml`)
6+
7+
- Automatically builds and deploys to GitHub Pages on every push to `main`
8+
- Can also be triggered manually from the Actions tab
9+
- Uses pnpm for efficient dependency installation
10+
- Builds with `pnpm run build`
11+
- Deploys the `dist` folder to GitHub Pages
12+
13+
### 2. Vite Configuration Update (`vite.config.ts`)
14+
15+
- Added `base: "/observable-plot-scatter-poc/"` for correct asset paths on GitHub Pages
16+
- This ensures all JavaScript, CSS, and other assets load correctly from the subdirectory
17+
18+
### 3. Jekyll Bypass (`public/.nojekyll`)
19+
20+
- Empty file that tells GitHub Pages not to process the site with Jekyll
21+
- Ensures files starting with underscores (like Vite's `_assets/`) are served correctly
22+
23+
## Manual Steps Required on GitHub
24+
25+
### One-Time Setup (Required)
26+
27+
1. **Go to Repository Settings**
28+
29+
- Navigate to: https://github.com/InformaticsMatters/observable-plot-scatter-poc/settings/pages
30+
31+
2. **Configure GitHub Pages**
32+
33+
- Under "Build and deployment"
34+
- **Source**: Select "**GitHub Actions**" from the dropdown
35+
- (Don't select "Deploy from a branch" - we want to use the Actions workflow)
36+
37+
3. **Wait for First Deployment**
38+
39+
- Push these changes to the `main` branch
40+
- Go to the **Actions** tab to watch the deployment progress
41+
- First deployment takes 2-3 minutes
42+
43+
4. **Access Your Site**
44+
- Once deployed, your app will be available at:
45+
- https://informaticsmatters.github.io/observable-plot-scatter-poc/
46+
47+
### That's It!
48+
49+
After the initial setup, every push to `main` will automatically trigger a new deployment. No further manual steps needed.
50+
51+
## Optional: Manual Deployment
52+
53+
You can trigger a deployment manually without pushing code:
54+
55+
1. Go to **Actions** tab: https://github.com/InformaticsMatters/observable-plot-scatter-poc/actions
56+
2. Click on "Deploy to GitHub Pages" workflow
57+
3. Click "Run workflow" button
58+
4. Select the `main` branch and click "Run workflow"
59+
60+
## Troubleshooting
61+
62+
### If deployment fails:
63+
64+
- Check the Actions tab for error logs
65+
- Ensure the repository has Pages enabled in Settings
66+
- Verify that Actions have write permissions (Settings → Actions → General → Workflow permissions)
67+
68+
### If site loads but shows 404:
69+
70+
- Verify the `base` path in `vite.config.ts` matches your repository name
71+
- Check that all files are in the `dist` folder after build
72+
73+
### To test locally before deploying:
74+
75+
```sh
76+
pnpm run build
77+
pnpm run preview
78+
```
79+
80+
This simulates the production build with the correct base path.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,36 @@ pnpm dev
2727

2828
Open your browser and navigate to the local dev server (typically `http://localhost:5173`).
2929

30+
## Deployment
31+
32+
This project is set up to automatically deploy to GitHub Pages on every push to the `main` branch.
33+
34+
**Live Demo:** https://informaticsmatters.github.io/observable-plot-scatter-poc/
35+
36+
### Initial Setup (One-time)
37+
38+
To enable GitHub Pages deployment, you need to configure your repository settings:
39+
40+
1. Go to your GitHub repository
41+
2. Navigate to **Settings****Pages** (in the left sidebar)
42+
3. Under **Build and deployment**:
43+
- **Source**: Select "GitHub Actions"
44+
4. That's it! The next push to `main` will trigger the deployment
45+
46+
The workflow will:
47+
48+
- Build the app using pnpm and Vite
49+
- Deploy the `dist` folder to GitHub Pages
50+
- Make your app available at `https://informaticsmatters.github.io/observable-plot-scatter-poc/`
51+
52+
### Manual Deployment
53+
54+
You can also trigger a deployment manually:
55+
56+
1. Go to **Actions** tab in your repository
57+
2. Select the "Deploy to GitHub Pages" workflow
58+
3. Click "Run workflow"
59+
3060
## Usage
3161

3262
### Interactive Selection

public/.nojekyll

Whitespace-only changes.

vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ import react from "@vitejs/plugin-react";
44
// https://vitejs.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7+
// Set base path for GitHub Pages deployment
8+
// Format: /repository-name/
9+
base: "/observable-plot-scatter-poc/",
710
});

0 commit comments

Comments
 (0)