fix: prune old releases via php container to avoid permission denied

composer-created vendor trees are not deletable by the host runner user

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
gouki
2026-07-18 15:04:27 +08:00
co-authored by Cursor
parent c412331154
commit c0579c502f
+17 -1
View File
@@ -113,6 +113,14 @@ run ln -s ../../shared/storage "$host_release/storage"
run docker exec --user "$php_user" --workdir "$container_release" \
"$PHP_CONTAINER" composer install \
--no-dev --no-interaction --prefer-dist --optimize-autoloader
# Composer runs as the PHP user and creates host files that the runner cannot
# delete later during release pruning. Normalize ownership back to the runner.
if id act_runner >/dev/null 2>&1; then
run chown -R act_runner:"$php_group" "$host_release"
else
run chgrp -R "$php_group" "$host_release"
fi
run chmod -R g+rwX "$host_release"
if test "$dry_run" != "true"; then
bash -c "$BACKUP_COMMAND"
@@ -146,7 +154,15 @@ if test "$dry_run" != "true"; then
'
)
if test "${#old_releases[@]}" -gt 0; then
rm -rf -- "${old_releases[@]}"
for old_release in "${old_releases[@]}"; do
release_name="$(basename "$old_release")"
# Prefer container-side delete so root-owned vendor trees are removable.
run docker exec "$PHP_CONTAINER" \
rm -rf "$CONTAINER_DEPLOY_ROOT/releases/$release_name"
if test -e "$old_release"; then
run rm -rf -- "$old_release"
fi
done
fi
fi