fix: auto-fix git permissions before pull in deployment

- Check if .git/FETCH_HEAD has write permission issues
- Auto-fix with sudo chown if needed
- Prevents "Permission denied" errors during git pull
- Ensures deployment user owns .git directory

Fixes deployment error: "error: cannot open '.git/FETCH_HEAD': Permission denied"
This commit is contained in:
juanatsap
2025-10-31 12:40:08 +00:00
parent 97ab363071
commit 7999af9107
+7
View File
@@ -29,6 +29,13 @@ jobs:
echo "🚀 Deploying to server..." echo "🚀 Deploying to server..."
echo "📥 Pulling latest changes..." echo "📥 Pulling latest changes..."
cd $REPO_PATH cd $REPO_PATH
# Fix git permissions if needed
if [ -f .git/FETCH_HEAD ] && [ ! -w .git/FETCH_HEAD ]; then
echo "🔧 Fixing git permissions..."
sudo chown -R $USER:$USER .git
fi
git pull origin main git pull origin main
echo "🔄 Restarting service..." echo "🔄 Restarting service..."