diff --git a/.gitignore b/.gitignore index 12de6ff..312d31b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,9 @@ content/output/* public/content/output/* public/content/output/shifts 2024.1.json !public/content/uploads/* +# Exclude the permits folder content from Git tracking but keep the folder itself +public/content/permits/* +!public/content/permits/.gitkeep .aider* /shift_generate_log_*.txt .env diff --git a/_deploy/entrypoint.sh b/_deploy/entrypoint.sh index be9f2b6..49b7946 100644 --- a/_deploy/entrypoint.sh +++ b/_deploy/entrypoint.sh @@ -27,11 +27,16 @@ if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then ######################################################################################## + # Backup permits folder if it exists + mkdir -p /tmp/content if [ -d "/app/public/content/permits" ]; then - mv /app/public/content/permits /tmp/content/permits + echo "Backing up permits folder..." | tee -a /app/logs/deploy.txt + cp -r /app/public/content/permits /tmp/content/ echo "Permits folder backed up successfully." | tee -a /app/logs/deploy.txt + ls -la /tmp/content/permits >> /app/logs/deploy.txt 2>&1 else - echo "Permits folder not found, skipping backup." | tee -a /app/logs/deploy.txt + echo "Permits folder not found, will create it after deployment." | tee -a /app/logs/deploy.txt + mkdir -p /tmp/content/permits fi # Run rsync with verbose output and itemize-changes @@ -55,13 +60,16 @@ if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then # Restore permits folder echo "Restoring permits folder..." | tee -a /app/logs/deploy.txt + # Always ensure the destination directory exists + mkdir -p /app/public/content + # Make sure the backed up permits exist before copying if [ -d "/tmp/content/permits" ]; then - # Ensure the destination directory exists - mkdir -p /app/public/content - mv /tmp/content/permits /app/public/content/permits + cp -r /tmp/content/permits /app/public/content/ echo "Permits folder restored successfully." | tee -a /app/logs/deploy.txt + ls -la /app/public/content/permits >> /app/logs/deploy.txt 2>&1 else - echo "No permits folder to restore." | tee -a /app/logs/deploy.txt + echo "ERROR: Backup permits folder not found. Creating empty directory." | tee -a /app/logs/deploy.txt + mkdir -p /app/public/content/permits fi # Check contents after restoration diff --git a/public/content/permits/.gitkeep b/public/content/permits/.gitkeep new file mode 100644 index 0000000..e69de29