From f6fc288aa639618de8f4408af7b6852741a0d85f Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 26 Aug 2026 21:10:59 -0700 Subject: [PATCH] fix: exclude deploy/ from changed-stack detection grep -E '^[^/.][^/]*/' matches ANY non-dot top-level folder in the changed-files list, including deploy/ -- the shared tooling folder synced by every deploy, not a stack. A PR touching only deploy/envparse.py caused stack-deploy.sh to be invoked with "deploy" as a stack name, which correctly errored ("No main compose file... in .../deploy") since deploy/ has no deploy.yaml. No live service was affected (the error occurs before any redeploy attempt), but it produced a confusing FAIL on an otherwise-correct change (PR #8) and could mask a real failure in the noise. Adds `| grep -v '^deploy$'` after the folder-name extraction in all 5 places this pattern appears (validate, provision-secrets x2, deploy, verify). deploy/ is already unconditionally rsynced at the top of the deploy step regardless of which stacks changed, so excluding it from the stack list is safe -- it will still be synced, just never treated as a deployable stack. --- .woodpecker/deploy.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.woodpecker/deploy.yml b/.woodpecker/deploy.yml index 8252443..424ff74 100644 --- a/.woodpecker/deploy.yml +++ b/.woodpecker/deploy.yml @@ -36,6 +36,18 @@ when: # until this was restored. Lesson: grep for the literal string '$${' and # diff the count against the previous version before ever committing a # full-file rewrite of this pipeline. +# +# 2026-08-26 FIX: FOLDER_STACKS/FOLDERS detection (grep -E '^[^/.][^/]*/') +# matches ANY non-dot top-level folder in the changed-files list, including +# deploy/ — the shared tooling folder, not a stack. A PR touching only +# deploy/envparse.py caused stack-deploy.sh to be invoked with "deploy" as +# a stack name, which correctly errored ("No main compose file... in +# .../deploy") since deploy/ has no deploy.yaml. No live service was +# affected (the error occurs before any redeploy), but it produced a +# confusing pipeline failure on an otherwise-correct change. deploy/ is +# already unconditionally rsynced at the top of the deploy step regardless +# of which stacks changed, so it's safe to exclude it from the stack list +# everywhere folders are detected below. # ───────────────────────────────────────────────────────────────────────────── steps: @@ -53,8 +65,9 @@ steps: FLAT=$(echo "$CHANGED_FILES" | grep -E '^[^/]+\.ya?ml$' || true) # Folder: any file under a subfolder (e.g. immich/immich.yml). - # Exclude dotfolders (.woodpecker, .git, .gitea, etc.) - FOLDERS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | sort -u || true) + # Exclude dotfolders (.woodpecker, .git, .gitea, etc.) and deploy/ + # (shared tooling, not a stack — see note above). + FOLDERS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | grep -v '^deploy$' | sort -u || true) [ -z "$FLAT" ] && [ -z "$FOLDERS" ] && echo "No stacks changed" && exit 0 @@ -180,14 +193,14 @@ steps: - | CHANGED_FILES=$(echo "${CI_PIPELINE_FILES}" | tr -d '[]"' | tr ',' '\n') FLAT_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/]+\.yaml$' | sed 's/\.yaml$//' || true) - FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | sort -u || true) + FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | grep -v '^deploy$' | sort -u || true) ALL_STACKS=$(printf '%s\n%s' "$FLAT_STACKS" "$FOLDER_STACKS" | grep -v '^$' | sort -u) [ -z "$ALL_STACKS" ] && echo "No stacks changed, skipping" && exit 0 - scp -o StrictHostKeyChecking=no deploy/create-secrets.sh root@$${SWARM_MANAGER_IP}:/tmp/cs.sh - | CHANGED_FILES=$(echo "${CI_PIPELINE_FILES}" | tr -d '[]"' | tr ',' '\n') FLAT_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/]+\.yaml$' | sed 's/\.yaml$//' || true) - FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | sort -u || true) + FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | grep -v '^deploy$' | sort -u || true) ALL_STACKS=$(printf '%s\n%s' "$FLAT_STACKS" "$FOLDER_STACKS" | grep -v '^$' | sort -u) for STACK in $ALL_STACKS; do @@ -318,7 +331,7 @@ steps: - | CHANGED_FILES=$(echo "${CI_PIPELINE_FILES}" | tr -d '[]"' | tr ',' '\n') FLAT_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/]+\.yaml$' | sed 's/\.yaml$//' || true) - FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | sort -u || true) + FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | grep -v '^deploy$' | sort -u || true) ALL_STACKS=$(printf '%s\n%s' "$FLAT_STACKS" "$FOLDER_STACKS" | grep -v '^$' | sort -u) [ -z "$ALL_STACKS" ] && echo "No stacks changed" && exit 0 @@ -372,7 +385,7 @@ steps: - | CHANGED_FILES=$(echo "${CI_PIPELINE_FILES}" | tr -d '[]"' | tr ',' '\n') FLAT_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/]+\.yaml$' | sed 's/\.yaml$//' || true) - FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | sort -u || true) + FOLDER_STACKS=$(echo "$CHANGED_FILES" | grep -E '^[^/.][^/]*/' | cut -d/ -f1 | grep -v '^deploy$' | sort -u || true) ALL_STACKS=$(printf '%s\n%s' "$FLAT_STACKS" "$FOLDER_STACKS" | grep -v '^$' | sort -u) [ -z "$ALL_STACKS" ] && exit 0 -- 2.54.0