Render photos individually, optimize gallery images, and prune old releases

This commit is contained in:
2026-09-19 16:20:07 +03:30
parent e112ed7640
commit 3ec6cdd3ec
210 changed files with 117 additions and 12 deletions
+18 -1
View File
@@ -35,7 +35,7 @@ ssh "${ssh_options[@]}" "$target" "mkdir -p '$release'"
# Checksums and hard links avoid retransmitting existing photos on every build.
printf -v transport 'ssh -i %q -p %q -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=%q' \
"$credentials/key" "$DEPLOY_PORT" "$credentials/known_hosts"
rsync -azc --delete --link-dest="$DEPLOY_PATH/current/" -e "$transport" _site/ "$target:$release/"
rsync -azc --no-times --delete --link-dest="$DEPLOY_PATH/current/" -e "$transport" _site/ "$target:$release/"
ssh "${ssh_options[@]}" "$target" "bash -s -- '$DEPLOY_PATH' '$release' '$GITHUB_RUN_NUMBER'" <<'REMOTE'
set -euo pipefail
destination=$1
@@ -58,5 +58,22 @@ chmod -R a+rX "$release"
temporary="$destination/.current-$run-$$"
ln -s "releases/$(basename "$release")" "$temporary"
mv -Tf "$temporary" "$destination/current"
python3 - "$destination" "$run" <<'PRUNE'
from pathlib import Path
import re
import shutil
import sys
root = Path(sys.argv[1])
current = (root / 'current').resolve(strict=True)
run = int(sys.argv[2])
for old in (root / 'releases').iterdir():
if not old.is_dir() or old.is_symlink() or old.resolve() == current:
continue
match = re.fullmatch(r'(\d+)(?:-\d+-[a-f0-9]{40})?', old.name)
# A higher-numbered release may still be transferring; it will prune us later.
if match and int(match.group(1)) <= run:
shutil.rmtree(old)
PRUNE
echo "Deployed $release"
REMOTE