-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy-to-pages.sh
More file actions
73 lines (57 loc) · 1.83 KB
/
Copy pathdeploy-to-pages.sh
File metadata and controls
73 lines (57 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Script to deploy the GitHub Copilot AIC Usage Analyzer to GitHub Pages manually
# Exit on error
set -e
# Variables - update these
GITHUB_USERNAME=$(git config user.name)
REPO_NAME="spark-template"
# Check if git is installed
if ! command -v git &> /dev/null; then
echo "Error: git is not installed."
exit 1
fi
# Check if we're in a git repository
if ! git rev-parse --is-inside-work-tree &> /dev/null; then
echo "Error: Not in a git repository."
exit 1
fi
# Build the application with correct base path
echo "Building application for GitHub Pages..."
export VITE_BASE_PATH="/${REPO_NAME}/"
# Create a temporary build config with the base path
cat > temp-vite.config.ts <<EOF
$(cat vite.config.ts | sed "s/build: {/build: {\n base: '\/${REPO_NAME}\/',/")
EOF
# Set deploy time for build
export DEPLOY_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "Setting deploy time: $DEPLOY_TIME"
# Build with temporary config
mv temp-vite.config.ts vite.config.ts
npm run build
git checkout -- vite.config.ts
echo "Build completed successfully."
# Create or navigate to gh-pages branch
if git show-ref --quiet refs/heads/gh-pages; then
echo "Checking out existing gh-pages branch..."
git checkout gh-pages
# Remove all files except .git
find . -mindepth 1 -maxdepth 1 -not -name .git -exec rm -rf {} \;
else
echo "Creating new gh-pages branch..."
git checkout --orphan gh-pages
git rm -rf .
fi
# Copy the build files
echo "Copying build files..."
cp -r dist/* .
touch .nojekyll
# Commit and push
echo "Committing changes..."
git add .
git commit -m "Deploy to GitHub Pages: $(date)"
echo "Pushing to GitHub..."
git push -u origin gh-pages
# Return to the main branch
git checkout main
echo "Deployment complete!"
echo "Your application should be available at: https://${GITHUB_USERNAME}.github.io/${REPO_NAME}/"