feat: add input to select specific image for manual trigger

This commit is contained in:
2025-12-08 08:05:28 +00:00
parent 6af9ff9ab2
commit 7555c25a58

View File

@@ -6,6 +6,11 @@ on:
paths: paths:
- 'images/**' - 'images/**'
workflow_dispatch: workflow_dispatch:
inputs:
image:
description: 'Image to build (e.g., terraform-ci). Leave empty to build all.'
required: false
default: ''
env: env:
REGISTRY: gitea.arnodo.fr REGISTRY: gitea.arnodo.fr
@@ -30,6 +35,12 @@ jobs:
echo "Event: ${{ gitea.event_name }}" echo "Event: ${{ gitea.event_name }}"
if [ "${{ gitea.event_name }}" = "workflow_dispatch" ]; then if [ "${{ gitea.event_name }}" = "workflow_dispatch" ]; then
if [ -n "${{ inputs.image }}" ]; then
# Manual trigger with specific image
echo "Manual trigger - building specific image: ${{ inputs.image }}"
IMAGES="${{ inputs.image }}"
else
# Manual trigger without input = build all
echo "Manual trigger - building all images" echo "Manual trigger - building all images"
IMAGES="" IMAGES=""
for dir in images/*/; do for dir in images/*/; do
@@ -39,7 +50,9 @@ jobs:
IMAGES="${IMAGES}${name} " IMAGES="${IMAGES}${name} "
fi fi
done done
fi
else else
# Push event = detect changes only
echo "Push event - detecting changes" 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' ' ') IMAGES=$(git diff --name-only HEAD~1 HEAD -- images/ 2>/dev/null | cut -d'/' -f2 | sort -u | grep -v '^$' | tr '\n' ' ')
fi fi
@@ -64,6 +77,17 @@ jobs:
IMAGE_NAME="${{ env.REGISTRY }}/damien/${IMAGE}" IMAGE_NAME="${{ env.REGISTRY }}/damien/${IMAGE}"
IMAGE_PATH="images/${IMAGE}" IMAGE_PATH="images/${IMAGE}"
# Validate image path exists
if [ ! -d "$IMAGE_PATH" ]; then
echo "❌ Error: Directory $IMAGE_PATH does not exist"
exit 1
fi
if [ ! -f "$IMAGE_PATH/Dockerfile" ]; then
echo "❌ Error: Dockerfile not found in $IMAGE_PATH"
exit 1
fi
echo "========================================" echo "========================================"
echo "Building ${IMAGE_NAME}:latest" echo "Building ${IMAGE_NAME}:latest"
echo "========================================" echo "========================================"