fix: simplify image detection with for loop and add debug output
This commit is contained in:
@@ -32,23 +32,35 @@ jobs:
|
||||
run: |
|
||||
echo "Event: ${{ gitea.event_name }}"
|
||||
|
||||
# Debug: show images directory
|
||||
echo "Content of images/:"
|
||||
ls -la images/ || echo "images/ not found"
|
||||
|
||||
if [ "${{ gitea.event_name }}" = "workflow_dispatch" ]; then
|
||||
echo "Manual trigger - building all images"
|
||||
# List all directories with Dockerfile
|
||||
IMAGES=$(find images -mindepth 1 -maxdepth 1 -type d -exec test -f {}/Dockerfile \; -print | xargs -n1 basename | tr '\n' ',' | sed 's/,$//')
|
||||
# Simple loop to find images with Dockerfile
|
||||
IMAGES=""
|
||||
for dir in images/*/; do
|
||||
if [ -f "${dir}Dockerfile" ]; then
|
||||
name=$(basename "$dir")
|
||||
echo "Found image: $name"
|
||||
IMAGES="${IMAGES}${name},"
|
||||
fi
|
||||
done
|
||||
IMAGES=${IMAGES%,} # Remove trailing comma
|
||||
else
|
||||
echo "Push event - detecting changes"
|
||||
IMAGES=$(git diff --name-only HEAD~1 HEAD -- images/ 2>/dev/null | cut -d'/' -f2 | sort -u | grep -v '^$' | tr '\n' ',' | sed 's/,$//')
|
||||
fi
|
||||
|
||||
echo "Detected images: $IMAGES"
|
||||
echo "Detected images: >$IMAGES<"
|
||||
|
||||
if [ -z "$IMAGES" ]; then
|
||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||
echo "image_list=[]" >> $GITHUB_OUTPUT
|
||||
else
|
||||
# Convert to JSON array
|
||||
JSON=$(echo "$IMAGES" | tr ',' '\n' | sed 's/.*/"&"/' | tr '\n' ',' | sed 's/,$//' | sed 's/^/[/' | sed 's/$/]/')
|
||||
# Convert to JSON array - simple approach
|
||||
JSON="[$(echo "$IMAGES" | sed 's/,/","/g' | sed 's/^/"/' | sed 's/$/"/' )]"
|
||||
echo "JSON: $JSON"
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
echo "image_list=$JSON" >> $GITHUB_OUTPUT
|
||||
|
||||
Reference in New Issue
Block a user