Skip to content

Commit 9ee33bf

Browse files
authored
ci: Enable floating tags (#1627)
* ci: Wire up floating tag support in reusable workflow * ci(krb5): Wire up floating tag support * ci(krb5): Change publish input handling * ci(krb5): Adjust case() inputs * ci(krb5): Temporarily trigger on PRs * ci: Use correct setup-tools action * ci(krb5): Try different method for defaulting * ci(krb6): Remove temporary code * ci(krb5): Try yet another way of defaulting This... is... very cumbersome. Thanks GitHub. * ci(krb5): Try fromJson to turn output into a proper bool * ci: Wire up floating tag support in all image workflows * ci(krb5): Temporarily hard-code version for testing * Revert "ci(krb5): Temporarily hard-code version for testing" This reverts commit d503797.
1 parent d072f6a commit 9ee33bf

27 files changed

Lines changed: 1436 additions & 152 deletions

‎.github/workflows/build_airflow.yaml‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ run-name: |
66
on:
77
workflow_dispatch:
88
inputs:
9-
skip-publish:
10-
description: Skip publishing and signing images
9+
publish:
10+
description: Publish and sign images
11+
type: boolean
12+
required: true
13+
default: true
14+
floating-tag:
15+
description: Produce floating tag
1116
type: boolean
1217
required: true
1318
default: false
@@ -31,8 +36,51 @@ on:
3136
permissions: {}
3237

3338
jobs:
39+
# This whole dance is only needed because GitHub Actions has no straight forward way of setting
40+
# default values for inputs which are not present due to the workflow being triggered by a
41+
# different event (workflow_dispatch vs push). Approaches tried (and used) in the past:
42+
#
43+
# - Negate the input (publish -> skip-publish) and use ${{ !inputs.skip-publish }} for the reusable
44+
# workflow. This works, but only by luck and it is cumbersome to wrap your head around.
45+
# We generally prefer non-negated terms for inputs.
46+
# - Use ${{ inputs.publish || true }}, but that results in 'true' even when the workflow is
47+
# dispatched with 'false' via the UI.
48+
# - Use ${{ case(inputs.publish, inputs.publish, true) }}, but that fails as well, because the
49+
# predicate must evaluate to a boolean value and apparently doesn't if the input is not present.
50+
defaults:
51+
name: Determine Defaults
52+
runs-on: ubuntu-latest
53+
outputs:
54+
floating-tag: ${{ steps.defaults.outputs.FLOATING_TAG }}
55+
publish: ${{ steps.defaults.outputs.PUBLISH }}
56+
steps:
57+
- id: defaults
58+
shell: bash
59+
env:
60+
INPUT_FLOATING_TAG: ${{ inputs.floating-tag }}
61+
INPUT_PUBLISH: ${{ inputs.publish }}
62+
run: |
63+
set -euo pipefail
64+
65+
# Default to false if not set/empty (if not triggered by workflow_dispatch)
66+
# Keep this default value in sync with the default value specified for workflow_dispatch!
67+
if [ -z "${INPUT_FLOATING_TAG:-}" ]; then
68+
echo "FLOATING_TAG=false" | tee -a "$GITHUB_OUTPUT"
69+
else
70+
echo "FLOATING_TAG=${INPUT_FLOATING_TAG}" | tee -a "$GITHUB_OUTPUT"
71+
fi
72+
73+
# Default to true if not set/empty (if not triggered by workflow_dispatch)
74+
# Keep this default value in sync with the default value specified for workflow_dispatch!
75+
if [ -z "${INPUT_PUBLISH:-}" ]; then
76+
echo "PUBLISH=true" | tee -a "$GITHUB_OUTPUT"
77+
else
78+
echo "PUBLISH=${INPUT_PUBLISH}" | tee -a "$GITHUB_OUTPUT"
79+
fi
80+
3481
build_image:
35-
name: Reusable Workflow
82+
name: Build Image(s)
83+
needs: [defaults]
3684
uses: ./.github/workflows/reusable_build_image.yaml
3785
secrets:
3886
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
@@ -43,7 +91,9 @@ jobs:
4391
contents: read
4492
with:
4593
product-name: airflow
46-
sdp-version: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
94+
# Syntax for case(): predicate, value if predicate is true, (more predicate+value pairs), default value
95+
# See https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#case
96+
sdp-version: ${{ case(github.ref_type == 'tag', github.ref_name, '0.0.0-dev') }}
4797
registry-namespace: sdp
48-
# Default to true if not set/empty (if not triggered by workflow_dispatch)
49-
publish: ${{ !inputs.skip-publish }}
98+
publish: ${{ fromJson(needs.defaults.outputs.publish) }}
99+
floating-tag: ${{ fromJson(needs.defaults.outputs.floating-tag) }}

‎.github/workflows/build_druid.yaml‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ run-name: |
66
on:
77
workflow_dispatch:
88
inputs:
9-
skip-publish:
10-
description: Skip publishing and signing images
9+
publish:
10+
description: Publish and sign images
11+
type: boolean
12+
required: true
13+
default: true
14+
floating-tag:
15+
description: Produce floating tag
1116
type: boolean
1217
required: true
1318
default: false
@@ -33,8 +38,51 @@ on:
3338
permissions: {}
3439

3540
jobs:
41+
# This whole dance is only needed because GitHub Actions has no straight forward way of setting
42+
# default values for inputs which are not present due to the workflow being triggered by a
43+
# different event (workflow_dispatch vs push). Approaches tried (and used) in the past:
44+
#
45+
# - Negate the input (publish -> skip-publish) and use ${{ !inputs.skip-publish }} for the reusable
46+
# workflow. This works, but only by luck and it is cumbersome to wrap your head around.
47+
# We generally prefer non-negated terms for inputs.
48+
# - Use ${{ inputs.publish || true }}, but that results in 'true' even when the workflow is
49+
# dispatched with 'false' via the UI.
50+
# - Use ${{ case(inputs.publish, inputs.publish, true) }}, but that fails as well, because the
51+
# predicate must evaluate to a boolean value and apparently doesn't if the input is not present.
52+
defaults:
53+
name: Determine Defaults
54+
runs-on: ubuntu-latest
55+
outputs:
56+
floating-tag: ${{ steps.defaults.outputs.FLOATING_TAG }}
57+
publish: ${{ steps.defaults.outputs.PUBLISH }}
58+
steps:
59+
- id: defaults
60+
shell: bash
61+
env:
62+
INPUT_FLOATING_TAG: ${{ inputs.floating-tag }}
63+
INPUT_PUBLISH: ${{ inputs.publish }}
64+
run: |
65+
set -euo pipefail
66+
67+
# Default to false if not set/empty (if not triggered by workflow_dispatch)
68+
# Keep this default value in sync with the default value specified for workflow_dispatch!
69+
if [ -z "${INPUT_FLOATING_TAG:-}" ]; then
70+
echo "FLOATING_TAG=false" | tee -a "$GITHUB_OUTPUT"
71+
else
72+
echo "FLOATING_TAG=${INPUT_FLOATING_TAG}" | tee -a "$GITHUB_OUTPUT"
73+
fi
74+
75+
# Default to true if not set/empty (if not triggered by workflow_dispatch)
76+
# Keep this default value in sync with the default value specified for workflow_dispatch!
77+
if [ -z "${INPUT_PUBLISH:-}" ]; then
78+
echo "PUBLISH=true" | tee -a "$GITHUB_OUTPUT"
79+
else
80+
echo "PUBLISH=${INPUT_PUBLISH}" | tee -a "$GITHUB_OUTPUT"
81+
fi
82+
3683
build_image:
37-
name: Reusable Workflow
84+
name: Build Image(s)
85+
needs: [defaults]
3886
uses: ./.github/workflows/reusable_build_image.yaml
3987
secrets:
4088
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
@@ -45,7 +93,9 @@ jobs:
4593
contents: read
4694
with:
4795
product-name: druid
48-
sdp-version: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
96+
# Syntax for case(): predicate, value if predicate is true, (more predicate+value pairs), default value
97+
# See https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#case
98+
sdp-version: ${{ case(github.ref_type == 'tag', github.ref_name, '0.0.0-dev') }}
4999
registry-namespace: sdp
50-
# Default to true if not set/empty (if not triggered by workflow_dispatch)
51-
publish: ${{ !inputs.skip-publish }}
100+
publish: ${{ fromJson(needs.defaults.outputs.publish) }}
101+
floating-tag: ${{ fromJson(needs.defaults.outputs.floating-tag) }}

‎.github/workflows/build_hadoop.yaml‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ run-name: |
66
on:
77
workflow_dispatch:
88
inputs:
9-
skip-publish:
10-
description: Skip publishing and signing images
9+
publish:
10+
description: Publish and sign images
11+
type: boolean
12+
required: true
13+
default: true
14+
floating-tag:
15+
description: Produce floating tag
1116
type: boolean
1217
required: true
1318
default: false
@@ -33,8 +38,51 @@ on:
3338
permissions: {}
3439

3540
jobs:
41+
# This whole dance is only needed because GitHub Actions has no straight forward way of setting
42+
# default values for inputs which are not present due to the workflow being triggered by a
43+
# different event (workflow_dispatch vs push). Approaches tried (and used) in the past:
44+
#
45+
# - Negate the input (publish -> skip-publish) and use ${{ !inputs.skip-publish }} for the reusable
46+
# workflow. This works, but only by luck and it is cumbersome to wrap your head around.
47+
# We generally prefer non-negated terms for inputs.
48+
# - Use ${{ inputs.publish || true }}, but that results in 'true' even when the workflow is
49+
# dispatched with 'false' via the UI.
50+
# - Use ${{ case(inputs.publish, inputs.publish, true) }}, but that fails as well, because the
51+
# predicate must evaluate to a boolean value and apparently doesn't if the input is not present.
52+
defaults:
53+
name: Determine Defaults
54+
runs-on: ubuntu-latest
55+
outputs:
56+
floating-tag: ${{ steps.defaults.outputs.FLOATING_TAG }}
57+
publish: ${{ steps.defaults.outputs.PUBLISH }}
58+
steps:
59+
- id: defaults
60+
shell: bash
61+
env:
62+
INPUT_FLOATING_TAG: ${{ inputs.floating-tag }}
63+
INPUT_PUBLISH: ${{ inputs.publish }}
64+
run: |
65+
set -euo pipefail
66+
67+
# Default to false if not set/empty (if not triggered by workflow_dispatch)
68+
# Keep this default value in sync with the default value specified for workflow_dispatch!
69+
if [ -z "${INPUT_FLOATING_TAG:-}" ]; then
70+
echo "FLOATING_TAG=false" | tee -a "$GITHUB_OUTPUT"
71+
else
72+
echo "FLOATING_TAG=${INPUT_FLOATING_TAG}" | tee -a "$GITHUB_OUTPUT"
73+
fi
74+
75+
# Default to true if not set/empty (if not triggered by workflow_dispatch)
76+
# Keep this default value in sync with the default value specified for workflow_dispatch!
77+
if [ -z "${INPUT_PUBLISH:-}" ]; then
78+
echo "PUBLISH=true" | tee -a "$GITHUB_OUTPUT"
79+
else
80+
echo "PUBLISH=${INPUT_PUBLISH}" | tee -a "$GITHUB_OUTPUT"
81+
fi
82+
3683
build_image:
37-
name: Reusable Workflow
84+
name: Build Image(s)
85+
needs: [defaults]
3886
uses: ./.github/workflows/reusable_build_image.yaml
3987
secrets:
4088
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
@@ -45,7 +93,9 @@ jobs:
4593
contents: read
4694
with:
4795
product-name: hadoop
48-
sdp-version: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
96+
# Syntax for case(): predicate, value if predicate is true, (more predicate+value pairs), default value
97+
# See https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#case
98+
sdp-version: ${{ case(github.ref_type == 'tag', github.ref_name, '0.0.0-dev') }}
4999
registry-namespace: sdp
50-
# Default to true if not set/empty (if not triggered by workflow_dispatch)
51-
publish: ${{ !inputs.skip-publish }}
100+
publish: ${{ fromJson(needs.defaults.outputs.publish) }}
101+
floating-tag: ${{ fromJson(needs.defaults.outputs.floating-tag) }}

‎.github/workflows/build_hbase.yaml‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ run-name: |
66
on:
77
workflow_dispatch:
88
inputs:
9-
skip-publish:
10-
description: Skip publishing and signing images
9+
publish:
10+
description: Publish and sign images
11+
type: boolean
12+
required: true
13+
default: true
14+
floating-tag:
15+
description: Produce floating tag
1116
type: boolean
1217
required: true
1318
default: false
@@ -34,8 +39,51 @@ on:
3439
permissions: {}
3540

3641
jobs:
42+
# This whole dance is only needed because GitHub Actions has no straight forward way of setting
43+
# default values for inputs which are not present due to the workflow being triggered by a
44+
# different event (workflow_dispatch vs push). Approaches tried (and used) in the past:
45+
#
46+
# - Negate the input (publish -> skip-publish) and use ${{ !inputs.skip-publish }} for the reusable
47+
# workflow. This works, but only by luck and it is cumbersome to wrap your head around.
48+
# We generally prefer non-negated terms for inputs.
49+
# - Use ${{ inputs.publish || true }}, but that results in 'true' even when the workflow is
50+
# dispatched with 'false' via the UI.
51+
# - Use ${{ case(inputs.publish, inputs.publish, true) }}, but that fails as well, because the
52+
# predicate must evaluate to a boolean value and apparently doesn't if the input is not present.
53+
defaults:
54+
name: Determine Defaults
55+
runs-on: ubuntu-latest
56+
outputs:
57+
floating-tag: ${{ steps.defaults.outputs.FLOATING_TAG }}
58+
publish: ${{ steps.defaults.outputs.PUBLISH }}
59+
steps:
60+
- id: defaults
61+
shell: bash
62+
env:
63+
INPUT_FLOATING_TAG: ${{ inputs.floating-tag }}
64+
INPUT_PUBLISH: ${{ inputs.publish }}
65+
run: |
66+
set -euo pipefail
67+
68+
# Default to false if not set/empty (if not triggered by workflow_dispatch)
69+
# Keep this default value in sync with the default value specified for workflow_dispatch!
70+
if [ -z "${INPUT_FLOATING_TAG:-}" ]; then
71+
echo "FLOATING_TAG=false" | tee -a "$GITHUB_OUTPUT"
72+
else
73+
echo "FLOATING_TAG=${INPUT_FLOATING_TAG}" | tee -a "$GITHUB_OUTPUT"
74+
fi
75+
76+
# Default to true if not set/empty (if not triggered by workflow_dispatch)
77+
# Keep this default value in sync with the default value specified for workflow_dispatch!
78+
if [ -z "${INPUT_PUBLISH:-}" ]; then
79+
echo "PUBLISH=true" | tee -a "$GITHUB_OUTPUT"
80+
else
81+
echo "PUBLISH=${INPUT_PUBLISH}" | tee -a "$GITHUB_OUTPUT"
82+
fi
83+
3784
build_image:
38-
name: Reusable Workflow
85+
name: Build Image(s)
86+
needs: [defaults]
3987
uses: ./.github/workflows/reusable_build_image.yaml
4088
secrets:
4189
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
@@ -46,7 +94,9 @@ jobs:
4694
contents: read
4795
with:
4896
product-name: hbase
49-
sdp-version: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
97+
# Syntax for case(): predicate, value if predicate is true, (more predicate+value pairs), default value
98+
# See https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#case
99+
sdp-version: ${{ case(github.ref_type == 'tag', github.ref_name, '0.0.0-dev') }}
50100
registry-namespace: sdp
51-
# Default to true if not set/empty (if not triggered by workflow_dispatch)
52-
publish: ${{ !inputs.skip-publish }}
101+
publish: ${{ fromJson(needs.defaults.outputs.publish) }}
102+
floating-tag: ${{ fromJson(needs.defaults.outputs.floating-tag) }}

0 commit comments

Comments
 (0)