revised deploy script so it does not pull from git

This commit is contained in:
michael 2025-11-03 09:08:56 -06:00
parent d1710c3642
commit 68771ebeb1
2 changed files with 100 additions and 9 deletions

View file

@ -421,8 +421,8 @@ sudo nano .env
sudo ./deploy.sh
```
That's it! The script will:
- Pull latest code from git
The script will ask you to confirm you've pulled the latest code, then:
- Verify git status and show current commit
- Create Python virtual environment
- Install all Python dependencies
- Install Composer PHP dependencies
@ -433,6 +433,8 @@ That's it! The script will:
- Start the API service
- Verify everything is working
**Note:** The deploy script does NOT pull code from git. You should pull the code you want to deploy BEFORE running the script. This gives you control over what version is deployed.
### Deployment Script Options
```bash
@ -448,6 +450,9 @@ sudo ./deploy.sh --frontend-only
# See what would be deployed without executing
sudo ./deploy.sh --dry-run
# Skip git status confirmation prompt (use with caution)
sudo ./deploy.sh --skip-git-check
# Verbose output for debugging
sudo ./deploy.sh --verbose
@ -455,23 +460,58 @@ sudo ./deploy.sh --verbose
sudo ./deploy.sh --help
```
**Typical Deployment Workflow:**
```bash
# 1. Pull latest code
cd /opt/voice2text
sudo git pull origin main
# 2. Review what will be deployed
git log -3 --oneline # See last 3 commits
git diff HEAD~1 # See changes in last commit
# 3. Deploy
sudo ./deploy.sh
# The script will show:
# - Current branch and commit
# - Commit message
# - Any uncommitted changes
# - Whether you're behind remote
# Then ask for confirmation before proceeding
```
### Updating Production (Subsequent Deployments)
After initial setup, updating is simple:
After initial setup, updating is a two-step process:
```bash
cd /opt/voice2text
# Step 1: Pull the code you want to deploy
sudo git pull origin main
# Or deploy a specific branch/tag:
# sudo git checkout v1.2.3
# sudo git pull origin feature-branch
# Step 2: Deploy the code
sudo ./deploy.sh
```
The script will:
- Pull latest changes
- Verify git status and show what will be deployed
- Ask for confirmation
- Update dependencies
- Restart the API service
- Update frontend files
- Verify API is responding
**Why separate git pull from deploy?**
- Gives you control over what version is deployed
- Allows you to review changes before deploying
- Lets you deploy specific branches, tags, or commits
- Prevents accidental deployment of unreviewed code
### Service Management
```bash

View file

@ -27,6 +27,7 @@ DRY_RUN=false
BACKEND_ONLY=false
FRONTEND_ONLY=false
VERBOSE=false
SKIP_GIT_CHECK=false
while [[ $# -gt 0 ]]; do
case $1 in
@ -46,6 +47,10 @@ while [[ $# -gt 0 ]]; do
VERBOSE=true
shift
;;
--skip-git-check)
SKIP_GIT_CHECK=true
shift
;;
--help|-h)
echo "Usage: sudo ./deploy.sh [options]"
echo ""
@ -54,7 +59,11 @@ while [[ $# -gt 0 ]]; do
echo " --backend-only Deploy only the Python API backend"
echo " --frontend-only Deploy only the PHP frontend"
echo " --verbose, -v Show detailed output"
echo " --skip-git-check Skip the git status verification prompt"
echo " --help, -h Show this help message"
echo ""
echo "Note: This script does NOT pull code from git."
echo " Pull the desired code/branch BEFORE running this script."
exit 0
;;
*)
@ -134,11 +143,53 @@ else
print_info "Updating existing deployment"
fi
# Git pull latest changes
print_header "Updating Code from Repository"
run_command git fetch origin
run_command git pull origin main
print_success "Code updated from repository"
# Verify git status
print_header "Verifying Code Status"
# Show current branch and commit
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT_COMMIT=$(git rev-parse --short HEAD)
COMMIT_MESSAGE=$(git log -1 --pretty=%B | head -n 1)
print_info "Current branch: ${GREEN}${CURRENT_BRANCH}${NC}"
print_info "Current commit: ${GREEN}${CURRENT_COMMIT}${NC}"
print_info "Commit message: ${CURRENT_COMMIT} - ${COMMIT_MESSAGE}"
# Check if there are uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
print_warning "There are uncommitted changes in the working directory:"
git status --short
echo ""
fi
# Check if local is behind remote
git fetch origin --quiet
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u} 2>/dev/null || echo "")
if [ -n "$REMOTE" ] && [ "$LOCAL" != "$REMOTE" ]; then
print_warning "Your local branch is not up to date with remote!"
print_info "Remote has newer commits. Consider: git pull origin ${CURRENT_BRANCH}"
fi
# Prompt user to confirm they've pulled the latest code
if [ "$SKIP_GIT_CHECK" != true ] && [ "$DRY_RUN" != true ]; then
echo ""
echo -e "${YELLOW}IMPORTANT:${NC} This script does NOT pull code from git."
echo -e " You should pull the desired code BEFORE running this script."
echo ""
read -p "Have you pulled the latest code you want to deploy? (y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_error "Deployment cancelled. Pull your code first, then run this script again."
exit 1
fi
print_success "Git status verified - proceeding with deployment"
else
if [ "$SKIP_GIT_CHECK" = true ]; then
print_info "Skipping git verification (--skip-git-check)"
fi
print_success "Proceeding with deployment of current code"
fi
# Deploy Backend
if [ "$FRONTEND_ONLY" != true ]; then