Skip to content

Commit cb7d2e3

Browse files
authored
Ability to provide app version from action for helm install (#74)
* Ability to provide app version from action for helm install * Add ability to override chart version * Fix * Incorrect build condition * Add parameters to readme * Set correct versions in the `helm push` command * Self-review fixes
1 parent de9bf39 commit cb7d2e3

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ Allows to build helm chart and push it to remote container repository.
126126
This action relies on git tags to be present in order to generate an artifact tag.
127127

128128
### Inputs
129-
| Name | Description | Optional | Default value |
130-
|----------------------------|:-----------------------------------------------|----------|---------------|
131-
| container_registry_address | Container registry address | False | |
132-
| application: | Application name | False | |
133-
| container_registry_user | Container registry username | False | |
134-
| container_registry_token | Container registry access token | False | |
135-
| helm_version | Version of helm to install | True | 3.9.2 |
136-
| helm_directory | Location of helm chart related to project root | True | .helm |
129+
| Name | Description | Optional | Default value |
130+
|----------------------------|:-----------------------------------------------------------------------------------|----------|---------------|
131+
| container_registry_address | Container registry address | False | |
132+
| application: | Application name | False | |
133+
| container_registry_user | Container registry username | False | |
134+
| container_registry_token | Container registry access token | False | |
135+
| helm_version | Version of helm to install | True | 3.9.2 |
136+
| helm_directory | Location of helm chart related to project root | True | .helm |
137+
| app_version | Application version to use for the chart. If omitted, the latest tag will be used. | True | |
138+
| chart_version | Chart version to use for the chart. If omitted, the latest tag will be used. | True | |
137139

138140
### Outputs
139141
No outputs defined

build_helm_chart/action.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ inputs:
3232
required: false
3333
default: '.helm'
3434

35+
app_version:
36+
description: Application version to use for the chart. If omitted, the latest tag will be used.
37+
required: false
38+
default: ''
39+
40+
chart_version:
41+
description: Chart version to use for the chart. If omitted, the latest tag will be used.
42+
required: false
43+
default: ''
44+
3545
runs:
3646
using: "composite"
3747
steps:
@@ -45,4 +55,6 @@ runs:
4555
REPO_LOGIN: ${{ inputs.container_registry_user }}
4656
REPO_TOKEN: ${{ inputs.container_registry_token }}
4757
APPLICATION: ${{ inputs.application }}
58+
APP_VERSION: ${{ inputs.app_version }}
59+
CHART_VERSION: ${{ inputs.chart_version }}
4860
shell: bash

build_helm_chart/build_chart.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,24 @@
1616

1717
set -Eeuo pipefail
1818

19-
appVersion=$(git describe --tags --abbrev=7)
20-
sed -i "s/appVersion: 0.0.0/appVersion: \"${appVersion:1}\"/" Chart.yaml
21-
sed -i "s/^version: .*/version: \"$appVersion\"/" Chart.yaml
19+
20+
if [[ -z "$APP_VERSION" ]]; then
21+
appVersion=$(git describe --tags --abbrev=7)
22+
else
23+
appVersion="$APP_VERSION"
24+
fi;
25+
26+
if [[ -z "$CHART_VERSION" ]]; then
27+
chartVersion=$(git describe --tags --abbrev=7)
28+
else
29+
chartVersion="$CHART_VERSION"
30+
fi;
31+
32+
33+
sed -i "s/appVersion: 0.0.0/appVersion: \"$appVersion\"/" Chart.yaml
34+
sed -i "s/^version: .*/version: \"$chartVersion\"/" Chart.yaml
2235

2336
helm package .
2437
echo "$REPO_TOKEN" | helm registry login "$REPO_ADDRESS" --username "$REPO_LOGIN" --password-stdin
2538
echo "oci://$REPO_ADDRESS/helm/"
26-
helm push "$APPLICATION-$appVersion.tgz" "oci://$REPO_ADDRESS/helm/"
39+
helm push "$APPLICATION-$chartVersion.tgz" "oci://$REPO_ADDRESS/helm/"

0 commit comments

Comments
 (0)