-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-commit-example
More file actions
executable file
·52 lines (40 loc) · 1.5 KB
/
post-commit-example
File metadata and controls
executable file
·52 lines (40 loc) · 1.5 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
#!/bin/bash
# Define source and destination paths
SOURCE_DIR="/Users/aes/GitRepos/CodeSpace-Portfolio/"
DEST_DIR="/Applications/XAMPP/xamppfiles/htdocs/codespace/MKTIME/"
# Copy this git commit file to git repo for git tracking
cp .git/hooks/post-commit post-commit-example
# Log file for errors
LOG_FILE="/tmp/post-commit-hook.log"
echo "Starting file sync from Git repository to web directory..."
# Create destination directory if it doesn't exist
if [ ! -d "$DEST_DIR" ]; then
mkdir -p "$DEST_DIR"
if [ $? -ne 0 ]; then
echo "Error: Failed to create destination directory $DEST_DIR" | tee -a "$LOG_FILE"
exit 1
fi
fi
# Use rsync to copy files, excluding .git directory and other unnecessary files
rsync -av --exclude='.git/' \
--exclude='.gitignore' \
--exclude='.DS_Store' \
--exclude='sql/' \
--exclude='node_modules/' \
--exclude='post-commit-example' \
--delete \
"$SOURCE_DIR" "$DEST_DIR" 2>> "$LOG_FILE"
# Check if rsync was successful
if [ $? -eq 0 ]; then
echo "✅ Success: Files have been copied to $DEST_DIR"
else
echo "❌ Error: Failed to copy files to web directory. Check $LOG_FILE for details"
exit 1
fi
ls -laR $DEST_DIR
# Set directory permissions to 755 (read and execute for everyone, write for owner)
chmod 755 $DEST_DIR/public/assets
chmod 755 $DEST_DIR/public/assets/images
# Set file permissions to 644 (read for everyone, write for owner)
chmod 644 $DEST_DIR/public/assets/images/*
exit 0