Skip to content

Commit 25622e7

Browse files
authored
feat(publish-helm-chart): Add merge-registry-values toggle (#100)
* feat(publish-helm-chart): Add merge registry values toggle * chore(publish-helm-chart): Add values files to smoke test * ci: Include publish-helm-action in path to trigger smoke build * fix(publish-helm-chart): Use correct input in condition Yikes! This just was silenty skipped. Cool stuff GitHub -.- * fix(publish-helm-chart): Add GITHUB_DEBUG env var * refactor(publish-helm-chart): Adjust values file lookup * chore(smoke): Add .helmignore file
1 parent 9848c55 commit 25622e7

6 files changed

Lines changed: 47 additions & 15 deletions

File tree

.github/workflows/smoke-build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- build-container-image/action.yaml
1010
- build-product-image/action.yaml
1111
- free-disk-space/action.yaml
12+
- publish-helm-chart/action.yaml
1213
- publish-image/action.yaml
1314
- publish-index-manifest/action.yaml
1415
- send-slack-notification/action.yaml

publish-helm-chart/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ It needs the `id-token: write` permission to be able to sign the Helm chart with
1212
1313
### Inputs
1414

15-
| Input | Required | Description |
16-
| ------------------------- | -------- | ----------------------------------------------------------------- |
17-
| `chart-registry-uri` | Yes | The URI of the Helm Chart registry |
18-
| `chart-registry-username` | Yes | The username used to login to the Helm Chart registry |
19-
| `chart-registry-password` | Yes | The password used to login to the Helm Chart registry |
20-
| `chart-repository` | Yes | Path to the Helm chart, for example `sdp-charts/kafka-operator` |
21-
| `chart-directory` | Yes | The directory where the Chart.yaml file is located |
22-
| `chart-version` | Yes | The Helm Chart version |
23-
| `app-version` | Yes | The app version to set in the Helm Chart |
24-
| `helm-version` | No | The version of helm |
25-
| `publish-and-sign` | No | Whether to publish and sign the Helm Chart. `"true"` or `"false"` |
15+
| Input | Required | Description |
16+
| ------------------------- | -------- | ------------------------------------------------------------------------------ |
17+
| `chart-registry-uri` | Yes | The URI of the Helm Chart registry |
18+
| `chart-registry-username` | Yes | The username used to login to the Helm Chart registry |
19+
| `chart-registry-password` | Yes | The password used to login to the Helm Chart registry |
20+
| `chart-repository` | Yes | Path to the Helm chart, for example `sdp-charts/kafka-operator` |
21+
| `chart-directory` | Yes | The directory where the Chart.yaml file is located |
22+
| `chart-version` | Yes | The Helm Chart version |
23+
| `app-version` | Yes | The app version to set in the Helm Chart |
24+
| `helm-version` | No | The version of helm |
25+
| `publish-and-sign` | No | Whether to publish and sign the Helm Chart. `"true"` or `"false"` |
26+
| `merge-registry-values` | No | Whether to merge a registry specific `values.yaml` file. `"true"` or `"false"` |
2627

2728
### Outputs
2829

publish-helm-chart/action.yaml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ inputs:
3939
publish-and-sign:
4040
description: Whether to publish and sign the packaged Helm Chart. Can be "true" or "false"
4141
default: "true"
42+
merge-registry-values:
43+
description: |
44+
Whether to merge a registry specific values.yaml file with the common one. Can be "true" or
45+
"false". The naming convention is as follows: `{chart-directory}/values/{chart-registry-uri}.yaml`
46+
default: "true"
47+
4248
runs:
4349
using: composite
4450
steps:
@@ -75,6 +81,26 @@ runs:
7581
username: ${{ inputs.chart-registry-username }}
7682
password: ${{ inputs.chart-registry-password }}
7783

84+
- name: Merge publish target specific values.yaml files
85+
if: inputs.merge-registry-values == 'true'
86+
env:
87+
CHART_REGISTRY_URI: ${{ inputs.chart-registry-uri }}
88+
CHART_DIRECTORY: ${{ inputs.chart-directory }}
89+
GITHUB_DEBUG: ${{ runner.debug }}
90+
shell: bash
91+
run: |
92+
set -euo pipefail
93+
[ -n "$GITHUB_DEBUG" ] && set -x
94+
95+
# This is directly taken from the official yq examples and merges all
96+
# listed files
97+
yq eval-all '. as $item ireduce ({}; . * $item )' \
98+
"$CHART_DIRECTORY/values/${CHART_REGISTRY_URI}.yaml" \
99+
"$CHART_DIRECTORY/values.yaml" \
100+
> "$CHART_DIRECTORY/values.merged.yaml"
101+
102+
mv "$CHART_DIRECTORY/values.merged.yaml" "$CHART_DIRECTORY/values.yaml"
103+
78104
- name: Package Helm Chart
79105
env:
80106
CHART_DIRECTORY: ${{ inputs.chart-directory }}
@@ -86,10 +112,6 @@ runs:
86112
set -euo pipefail
87113
[ -n "$GITHUB_DEBUG" ] && set -x
88114
89-
# Set the Helm Chart version
90-
# yq ".version = \"$CHART_VERSION\"" < "$CHART_DIRECTORY/Chart.yaml" > "$CHART_DIRECTORY/Chart.new.yaml"
91-
# mv "$CHART_DIRECTORY/Chart.new.yaml" "$CHART_DIRECTORY/Chart.yaml"
92-
93115
# Create temporary directory to store the Helm Chart
94116
TEMP_CHART_DIR=$(mktemp -d)
95117
echo "TEMP_CHART_DIR=$TEMP_CHART_DIR" | tee -a "$GITHUB_ENV"

smoke/helm-chart/.helmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.helmignore
2+
values/

smoke/helm-chart/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
image:
3+
repository: smoke/helm-chart
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
image:
3+
registry: oci.stackable.tech

0 commit comments

Comments
 (0)