-
-
Notifications
You must be signed in to change notification settings - Fork 6
97 lines (91 loc) · 3.87 KB
/
Copy pathbuild_java-devel.yaml
File metadata and controls
97 lines (91 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
name: Build Java Development
run-name: |
Build Java Development (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 1 1/2 * * # https://crontab.guru/#0_1_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[]'
- java-devel/**
- .github/actions/**
- .github/workflows/build_java-devel.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)
needs: [defaults]
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: java-devel
# 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) }}