From 82fd3462c6ab2224387becec1bf353569ecf4a64 Mon Sep 17 00:00:00 2001 From: "@permadeath.com" Date: Tue, 18 Aug 2026 10:51:22 -0400 Subject: [PATCH] fix: upload in parallel --- scripts/deploy-site.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/deploy-site.sh b/scripts/deploy-site.sh index b37d983..45bad61 100755 --- a/scripts/deploy-site.sh +++ b/scripts/deploy-site.sh @@ -89,9 +89,22 @@ upload() { aws s3 cp --no-progress "${file}" "s3://${bucket}/${prefix}/${key}" "${args[@]}" } -while IFS= read -r -d '' file; do - upload "${file}" "${file#"${repo_root}/web/dist/"}" -done < <(find "${repo_root}/web/dist" -type f -print0) +# Derive the key from the path so xargs can hand each worker a single +# argument. +upload_from_dist() { + upload "$1" "${1#"${repo_root}/web/dist/"}" +} + +# One `aws` process per file costs ~0.5s of Python startup and a fresh TLS +# handshake, which for a tree this small is nearly all of the upload time. +# Run ten at a time. xargs exits non-zero if any single upload failed, and +# `set -e` turns that into a failed deploy, so a partial release tree can +# never reach the `tofu apply` below that points CloudFront at it. +export -f upload upload_from_dist content_type +export bucket prefix repo_root + +find "${repo_root}/web/dist" -type f -print0 \ + | xargs -0 -r -P 10 -I {} bash -c 'upload_from_dist "$@"' _ {} upload "${repo_root}/oauth/client-metadata.json" "client-metadata.json" echo "deploy-site: uploaded release to s3://${bucket}/${prefix}/" -- 2.51.2