Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 3 additions & 147 deletions .github/workflows/deploy-to-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,159 +35,15 @@ jobs:
node-version: "18"
cache: 'npm'

- name: Create simplified vite config
run: |
cat > vite.config.js << 'EOF'
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { resolve } from 'path';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
build: {
base: "/github-copilot-usage/",
outDir: 'dist'
},
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
}
});
EOF

- name: Create simplified package.json
run: |
cat > simplified-package.json << 'EOF'
{
"name": "github-copilot-usage-analyzer",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@heroicons/react": "^2.2.0",
"@phosphor-icons/react": "^2.1.7",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-accordion": "^1.2.3",
"@radix-ui/react-alert-dialog": "^1.1.6",
"@radix-ui/react-aspect-ratio": "^1.1.2",
"@radix-ui/react-avatar": "^1.1.3",
"@radix-ui/react-checkbox": "^1.1.4",
"@radix-ui/react-collapsible": "^1.1.3",
"@radix-ui/react-context-menu": "^2.2.6",
"@radix-ui/react-dialog": "^1.1.6",
"@radix-ui/react-dropdown-menu": "^2.1.6",
"@radix-ui/react-hover-card": "^1.1.6",
"@radix-ui/react-label": "^2.1.2",
"@radix-ui/react-menubar": "^1.1.6",
"@radix-ui/react-navigation-menu": "^1.2.5",
"@radix-ui/react-popover": "^1.1.6",
"@radix-ui/react-progress": "^1.1.2",
"@radix-ui/react-radio-group": "^1.2.3",
"@radix-ui/react-scroll-area": "^1.2.9",
"@radix-ui/react-select": "^2.1.6",
"@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-slider": "^1.2.3",
"@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-switch": "^1.1.3",
"@radix-ui/react-tabs": "^1.1.3",
"@radix-ui/react-toggle": "^1.1.2",
"@radix-ui/react-toggle-group": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.8",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"d3": "^7.9.0",
"date-fns": "^3.6.0",
"embla-carousel-react": "^8.5.2",
"framer-motion": "^12.6.2",
"input-otp": "^1.4.2",
"lucide-react": "^0.484.0",
"marked": "^15.0.7",
"react": "^19.0.0",
"react-day-picker": "^9.6.7",
"react-dom": "^19.0.0",
"react-hook-form": "^7.54.2",
"react-resizable-panels": "^2.1.7",
"recharts": "^2.15.1",
"sonner": "^2.0.1",
"tailwind-merge": "^3.0.2",
"three": "^0.175.0",
"tw-animate-css": "^1.2.4",
"uuid": "^11.1.0",
"vaul": "^1.1.2",
"zod": "^3.24.2"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.17",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"@vitejs/plugin-react": "^4.3.4",
"tailwindcss": "^4.0.17",
"typescript": "~5.7.2",
"vite": "^6.3.5"
}
}
EOF
mv simplified-package.json package.json

- name: Install dependencies
run: npm install

- name: Create modified App with no Spark dependencies
run: |
# Create a file to replace @github/spark imports
mkdir -p src/spark-shims
cat > src/spark-shims/hooks.js << 'EOF'
import { useState } from 'react';

// Simple localStorage-based shim for useKV hook
export function useKV(key, initialValue) {
const storageKey = `kv-${key}`;

// Get from localStorage
const stored = localStorage.getItem(storageKey);
const initial = stored !== null ? JSON.parse(stored) : initialValue;

const [value, setValue] = useState(initial);

const setValueAndStore = (newValue) => {
const valueToStore = newValue instanceof Function ? newValue(value) : newValue;
setValue(valueToStore);
localStorage.setItem(storageKey, JSON.stringify(valueToStore));
};

const deleteValue = () => {
setValue(null);
localStorage.removeItem(storageKey);
};

return [value, setValueAndStore, deleteValue];
}
EOF

- name: Update imports in code
run: |
# Replace imports from @github/spark/hooks with our shim
find src -type f -name "*.ts" -o -name "*.tsx" | xargs sed -i 's/import {.*} from "@github\/spark\/hooks"/import { useKV } from "..\/spark-shims\/hooks"/g'

- name: Use GitHub Pages main file
run: |
# Use the main-github-pages.tsx instead of main.tsx to avoid Spark imports
cp src/main-github-pages.tsx src/main.tsx
- name: Build for GitHub Pages
run: npm run build:pages

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Build
run: npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand All @@ -196,7 +52,7 @@ jobs:
# Deployment job
deploy:
# Only deploy on main branch
if: github.ref == 'refs/heads/main'
# if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
2 changes: 1 addition & 1 deletion build-for-gh-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cp src/main-github-pages.tsx src/main.tsx

# Build using Vite with the GitHub Pages config
vite build --config vite.github-pages.config.ts
npx vite build --config vite.github-pages.config.ts

# Restore the original main file if you need to continue local development
git checkout src/main.tsx
Expand Down
1 change: 1 addition & 0 deletions src/main-github-pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import "./main.css"
import "./styles/theme.css"
import "./index.css"
// @github/spark/spark import is excluded and handled externally

Expand Down
Loading