try to fix permits upload restore/merge upon deployment

This commit is contained in:
Dobromir Popov
2025-04-10 02:01:53 +03:00
parent 6f5166254b
commit 8f066c17e7
3 changed files with 17 additions and 6 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -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

View File