Actions: relax perms before cleanup to avoid Permission denied; keep docker root fallback

This commit is contained in:
Esdras Renan 2025-10-19 01:38:26 -03:00
parent f3cb9038b7
commit fc1bdc248b

View file

@ -269,6 +269,7 @@ jobs:
echo "Skipping active dir (in use by APP_DIR): $dir"; continue echo "Skipping active dir (in use by APP_DIR): $dir"; continue
fi fi
echo "Removing $dir" echo "Removing $dir"
chmod -R u+rwX "$dir" 2>/dev/null || true
rm -rf "$dir" || { rm -rf "$dir" || {
echo "Local rm failed, falling back to docker (root) cleanup for $dir..." echo "Local rm failed, falling back to docker (root) cleanup for $dir..."
docker run --rm -v "$dir":/target alpine:3 sh -lc 'chown -R 1000:1000 /target 2>/dev/null || true; chmod -R u+rwX /target 2>/dev/null || true; rm -rf /target/* /target/.[!.]* /target/..?* 2>/dev/null || true' || true docker run --rm -v "$dir":/target alpine:3 sh -lc 'chown -R 1000:1000 /target 2>/dev/null || true; chmod -R u+rwX /target 2>/dev/null || true; rm -rf /target/* /target/.[!.]* /target/..?* 2>/dev/null || true' || true
@ -397,6 +398,7 @@ jobs:
echo "$LIST" | sed "1,${KEEP}d" | while read dir; do echo "$LIST" | sed "1,${KEEP}d" | while read dir; do
[ -z "$dir" ] && continue [ -z "$dir" ] && continue
echo "Removing $dir" echo "Removing $dir"
chmod -R u+rwX "$dir" 2>/dev/null || true
rm -rf "$dir" || { rm -rf "$dir" || {
echo "Local rm failed, falling back to docker (root) cleanup for $dir..." echo "Local rm failed, falling back to docker (root) cleanup for $dir..."
docker run --rm -v "$dir":/target alpine:3 sh -lc 'chown -R 1000:1000 /target 2>/dev/null || true; chmod -R u+rwX /target 2>/dev/null || true; rm -rf /target/* /target/.[!.]* /target/..?* 2>/dev/null || true' || true docker run --rm -v "$dir":/target alpine:3 sh -lc 'chown -R 1000:1000 /target 2>/dev/null || true; chmod -R u+rwX /target 2>/dev/null || true; rm -rf /target/* /target/.[!.]* /target/..?* 2>/dev/null || true' || true