From ad71a2fd777386aacd88742acf4d4c93609cc15c Mon Sep 17 00:00:00 2001 From: Zbigniew Date: Fri, 24 Oct 2025 18:45:11 -0500 Subject: [PATCH 1/2] feat: add pre-build-targets for running lint/test before final build --- action.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/action.yml b/action.yml index 57843a8..adb63ed 100644 --- a/action.yml +++ b/action.yml @@ -58,6 +58,10 @@ inputs: description: 'Target build stage (optional, for multi-stage builds)' required: false default: '' + pre-build-targets: + description: 'Comma-separated list of build targets to run before final build (e.g., "lint,test" for validation stages)' + required: false + default: '' outputs: tag: # id of output description: 'Tag used for the docker image' @@ -137,6 +141,23 @@ runs: touch /tmp/build-secrets/uvconfig.toml fi shell: bash + - name: Run pre-build targets with Depot + if: ${{ inputs.depot-token != '' && inputs.pre-build-targets != '' }} + shell: bash + run: | + IFS=',' read -ra TARGETS <<< "${{ inputs.pre-build-targets }}" + for target in "${TARGETS[@]}"; do + echo "Building target: $target" + depot build \ + --project ${{ inputs.depot-project }} \ + --token ${{ inputs.depot-token }} \ + --platform ${{ inputs.platforms }} \ + --target "$target" \ + --secret id=pipconf,src=/tmp/build-secrets/pipconf \ + --secret id=uvconfig,src=/tmp/build-secrets/uvconfig.toml \ + --file ${{ inputs.dockerfile }} \ + ${{ inputs.docker-build-context }} + done - name: Build and push with Depot id: docker_build_depot if: ${{ inputs.depot-token != '' }} From b12ee81e8c580bafed7fb51a36886f10aedd45c3 Mon Sep 17 00:00:00 2001 From: Zbigniew Date: Tue, 28 Oct 2025 20:33:09 -0500 Subject: [PATCH 2/2] feat: auto-detect lint and test stages in Dockerfile --- action.yml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index adb63ed..6838189 100644 --- a/action.yml +++ b/action.yml @@ -141,11 +141,42 @@ runs: touch /tmp/build-secrets/uvconfig.toml fi shell: bash + - name: Auto-detect build stages + id: detect-stages + run: | + DOCKERFILE="${{ inputs.docker-build-context }}/${{ inputs.dockerfile }}" + DETECTED_TARGETS="" + + # Check for lint stage + if grep -q "^FROM .* AS lint" "$DOCKERFILE"; then + echo "Detected lint stage" + DETECTED_TARGETS="lint" + fi + + # Check for test stage + if grep -q "^FROM .* AS test" "$DOCKERFILE"; then + echo "Detected test stage" + if [ -n "$DETECTED_TARGETS" ]; then + DETECTED_TARGETS="${DETECTED_TARGETS},test" + else + DETECTED_TARGETS="test" + fi + fi + + # Use detected targets if pre-build-targets not explicitly set + if [ -z "${{ inputs.pre-build-targets }}" ]; then + echo "auto-targets=$DETECTED_TARGETS" >> $GITHUB_OUTPUT + echo "Using auto-detected targets: $DETECTED_TARGETS" + else + echo "auto-targets=${{ inputs.pre-build-targets }}" >> $GITHUB_OUTPUT + echo "Using explicitly configured targets: ${{ inputs.pre-build-targets }}" + fi + shell: bash - name: Run pre-build targets with Depot - if: ${{ inputs.depot-token != '' && inputs.pre-build-targets != '' }} + if: ${{ inputs.depot-token != '' && steps.detect-stages.outputs.auto-targets != '' }} shell: bash run: | - IFS=',' read -ra TARGETS <<< "${{ inputs.pre-build-targets }}" + IFS=',' read -ra TARGETS <<< "${{ steps.detect-stages.outputs.auto-targets }}" for target in "${TARGETS[@]}"; do echo "Building target: $target" depot build \