Skip to content

Build Testing Tools (attempt #1) #433

Build Testing Tools (attempt #1)

Build Testing Tools (attempt #1) #433

---
name: Build Testing Tools
run-name: |
Build Testing Tools (attempt #${{ github.run_attempt }})
on:
workflow_dispatch:
inputs:
publish:
description: Publish and sign images
type: boolean
required: true
default: true
floating-tag:
description: Produce floating tag
type: boolean
required: true
default: false
schedule:
- cron: 0 0 1/2 * * # https://crontab.guru/#0_0_1/2_*_*
push:
branches: [main]
tags:
- "[0-9][0-9].[0-9]+.[0-9]+"
- "[0-9][0-9].[0-9]+.[0-9]+-rc[0-9]+"
paths:
# To check dependencies, run this ( you will need to consider transitive dependencies)
# bake --product PRODUCT -d | grep -v 'docker buildx bake' | jq '.target | keys[]'
- testing-tools/**
- .github/actions/**
- .github/workflows/build_testing-tools.yaml
- .github/workflows/reusable_build_image.yaml
permissions: {}
jobs:
# This whole dance is only needed because GitHub Actions has no straight forward way of setting
# default values for inputs which are not present due to the workflow being triggered by a
# different event (workflow_dispatch vs push). Approaches tried (and used) in the past:
#
# - Negate the input (publish -> skip-publish) and use ${{ !inputs.skip-publish }} for the reusable
# workflow. This works, but only by luck and it is cumbersome to wrap your head around.
# We generally prefer non-negated terms for inputs.
# - Use ${{ inputs.publish || true }}, but that results in 'true' even when the workflow is
# dispatched with 'false' via the UI.
# - Use ${{ case(inputs.publish, inputs.publish, true) }}, but that fails as well, because the
# predicate must evaluate to a boolean value and apparently doesn't if the input is not present.
defaults:
name: Determine Defaults
runs-on: ubuntu-latest
outputs:
floating-tag: ${{ steps.defaults.outputs.FLOATING_TAG }}
publish: ${{ steps.defaults.outputs.PUBLISH }}
steps:
- id: defaults
shell: bash
env:
INPUT_FLOATING_TAG: ${{ inputs.floating-tag }}
INPUT_PUBLISH: ${{ inputs.publish }}
run: |
set -euo pipefail
# Default to false if not set/empty (if not triggered by workflow_dispatch)
# Keep this default value in sync with the default value specified for workflow_dispatch!
if [ -z "${INPUT_FLOATING_TAG:-}" ]; then
echo "FLOATING_TAG=false" | tee -a "$GITHUB_OUTPUT"
else
echo "FLOATING_TAG=${INPUT_FLOATING_TAG}" | tee -a "$GITHUB_OUTPUT"
fi
# Default to true if not set/empty (if not triggered by workflow_dispatch)
# Keep this default value in sync with the default value specified for workflow_dispatch!
if [ -z "${INPUT_PUBLISH:-}" ]; then
echo "PUBLISH=true" | tee -a "$GITHUB_OUTPUT"
else
echo "PUBLISH=${INPUT_PUBLISH}" | tee -a "$GITHUB_OUTPUT"
fi
build_image:
name: Build Image(s) (${{ matrix.product-name }})
needs: [defaults]
strategy:
fail-fast: false
matrix:
product-name:
- testing-tools
- testing-tools/nifi
- testing-tools/trino
- testing-tools/hive
uses: ./.github/workflows/reusable_build_image.yaml
secrets:
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
quay-robot-secret: ${{ secrets.QUAY_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
slack-token: ${{ secrets.SLACK_CONTAINER_IMAGE_TOKEN }}
permissions:
id-token: write
contents: read
with:
product-name: ${{ matrix.product-name }}
# Syntax for case(): predicate, value if predicate is true, (more predicate+value pairs), default value
# See https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#case
sdp-version: ${{ case(github.ref_type == 'tag', github.ref_name, '0.0.0-dev') }}
registry-namespace: sdp
publish: ${{ fromJson(needs.defaults.outputs.publish) }}
floating-tag: ${{ fromJson(needs.defaults.outputs.floating-tag) }}