-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-to-github.sh
More file actions
executable file
·74 lines (61 loc) · 2.11 KB
/
deploy-to-github.sh
File metadata and controls
executable file
·74 lines (61 loc) · 2.11 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
74
#!/bin/bash
set -e
# Configuration
REPO_URL="https://github.com/DspreadOrg/docs.git"
BRANCH="main"
# Clean up any previous build artifacts
echo "Cleaning up project..."
rm -rf ./.next
rm -rf ./out
# Create a temporary directory for the deployment
TEMP_DIR="$(mktemp -d 2>/dev/null || mktemp -d -t 'docs-deploy')"
echo "Using temporary directory: $TEMP_DIR"
# Initialize a new git repository in the temp directory
echo "Initializing Git repository..."
mkdir -p "$TEMP_DIR"
cd "$TEMP_DIR"
git init
git config --local user.name "Documentation Deployment"
git config --local user.email "docs-deploy@example.com"
git remote add origin "$REPO_URL"
# Create an empty commit to start with
git commit --allow-empty -m "Initial commit"
# Copy only the necessary files to the temp directory
echo "Copying documentation files..."
cd - # Go back to the original directory
# Copy files, excluding node_modules, build artifacts, and git files
find . -type f \
-not -path "*/node_modules/*" \
-not -path "*/.next/*" \
-not -path "*/out/*" \
-not -path "*/.git/*" \
-not -path "*/temp-docs-deploy/*" | while read file; do
# Create the directory structure in the temp directory
mkdir -p "$TEMP_DIR/$(dirname "$file")"
# Copy the file
cp "$file" "$TEMP_DIR/$file"
done
# Make sure .github directory and other hidden files are copied
cp -r ./.github "$TEMP_DIR/" 2>/dev/null || true
cp .gitignore "$TEMP_DIR/" 2>/dev/null || true
cp .nojekyll "$TEMP_DIR/" 2>/dev/null || true
# Navigate to the temporary directory
cd "$TEMP_DIR"
# Add all files
echo "Adding files to Git..."
git add -A
# Only commit if there are changes
if git diff --cached --quiet; then
echo "No changes detected. Nothing to commit."
else
echo "Committing changes..."
git commit -m "Update documentation website with improved feature cards and fixed GitHub Actions workflow"
# Push changes directly to GitHub
echo "Pushing to GitHub repository: $REPO_URL"
git push -f origin HEAD:$BRANCH
echo "Deployment complete! Your documentation has been pushed to $REPO_URL"
fi
# Clean up the temporary directory
cd -
rm -rf "$TEMP_DIR"
echo "Temporary directory cleaned up."