feat: add input to select specific image for manual trigger
This commit is contained in:
@@ -6,6 +6,11 @@ on:
|
||||
paths:
|
||||
- 'images/**'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
image:
|
||||
description: 'Image to build (e.g., terraform-ci). Leave empty to build all.'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
env:
|
||||
REGISTRY: gitea.arnodo.fr
|
||||
@@ -30,6 +35,12 @@ jobs:
|
||||
echo "Event: ${{ gitea.event_name }}"
|
||||
|
||||
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"
|
||||
IMAGES=""
|
||||
for dir in images/*/; do
|
||||
@@ -39,7 +50,9 @@ jobs:
|
||||
IMAGES="${IMAGES}${name} "
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
# Push event = detect changes only
|
||||
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' ' ')
|
||||
fi
|
||||
@@ -64,6 +77,17 @@ jobs:
|
||||
IMAGE_NAME="${{ env.REGISTRY }}/damien/${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 "Building ${IMAGE_NAME}:latest"
|
||||
echo "========================================"
|
||||
|
||||
Reference in New Issue
Block a user