Skip to content

Commit f06c3ae

Browse files
committed
feat(helm): add new action 'update-chart-values'
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent cb3b9dd commit f06c3ae

6 files changed

Lines changed: 385 additions & 97 deletions

File tree

.github/workflows/__shared-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ jobs:
5151
permissions:
5252
contents: read
5353

54+
test-action-helm-update-chart-values:
55+
needs: linter
56+
uses: ./.github/workflows/__test-action-helm-update-chart-values.yml
57+
permissions:
58+
contents: read
59+
5460
test-action-helm-release-chart:
5561
needs: linter
5662
uses: ./.github/workflows/__test-action-helm-release-chart.yml
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
name: Test for "helm/update-chart-values" action
3+
run-name: Test for "actions/helm/update-chart-values" action
4+
5+
on: # yamllint disable-line rule:truthy
6+
workflow_call:
7+
8+
permissions: {}
9+
10+
jobs:
11+
test-simple-chart:
12+
name: Test for "helm/update-chart-values" action with simple chart
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false
20+
21+
- name: Act
22+
uses: ./actions/helm/update-chart-values
23+
with:
24+
path: tests/charts/application
25+
values: |
26+
[
27+
{ "path": ".image.registry", "value": "ghcr.io" },
28+
{
29+
"path": ".image.repository",
30+
"value": "hoverkraft-tech/ci-github-container/application"
31+
},
32+
{ "path": ".image.tag", "value": "0.2.0" }
33+
]
34+
35+
- name: Assert - Check updated chart files
36+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
37+
with:
38+
script: |
39+
const assert = require('node:assert');
40+
const fs = require('node:fs');
41+
42+
const chartContent = fs.readFileSync('tests/charts/application/Chart.yaml', 'utf8');
43+
assert.match(chartContent, /name:\s+"test-application"/, 'root chart name should stay unchanged');
44+
assert.match(chartContent, /version:\s+0\.0\.0/, 'root chart version should stay unchanged');
45+
assert.match(chartContent, /appVersion:\s+"0\.0\.0"/, 'root chart appVersion should stay unchanged');
46+
47+
const valuesContent = fs.readFileSync('tests/charts/application/values.yaml', 'utf8');
48+
assert.match(valuesContent, /registry:\s+ghcr\.io/, 'image registry should be updated');
49+
assert.match(valuesContent, /repository:\s+hoverkraft-tech\/ci-github-container\/application/, 'image repository should be updated');
50+
assert.match(valuesContent, /tag:\s+0\.2\.0/, 'image tag should be updated');
51+
52+
test-umbrella-chart:
53+
name: Test for "helm/update-chart-values" action with umbrella chart
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: read
57+
steps:
58+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
with:
60+
persist-credentials: false
61+
62+
- name: Act
63+
uses: ./actions/helm/update-chart-values
64+
with:
65+
path: tests/charts/umbrella-application
66+
values: |
67+
[
68+
{ "file": "charts/app/values.yaml", "path": ".image.registry", "value": "ghcr.io" },
69+
{
70+
"file": "charts/app/values.yaml",
71+
"path": ".image.repository",
72+
"value": "hoverkraft-tech/ci-github-container/umbrella-application"
73+
},
74+
{ "file": "charts/app/values.yaml", "path": ".image.tag", "value": "0.2.0" }
75+
]
76+
77+
- name: Assert - Check updated umbrella chart files
78+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
79+
with:
80+
script: |
81+
const assert = require('node:assert');
82+
const fs = require('node:fs');
83+
84+
const rootChartContent = fs.readFileSync('tests/charts/umbrella-application/Chart.yaml', 'utf8');
85+
assert.match(rootChartContent, /name:\s+test-umbrella-application/, 'root chart name should stay unchanged');
86+
assert.match(rootChartContent, /version:\s+0\.1\.0/, 'root chart version should stay unchanged');
87+
assert.match(rootChartContent, /appVersion:\s+"0\.1\.0"/, 'root chart appVersion should stay unchanged');
88+
assert.match(rootChartContent, /version:\s+0\.0\.0\s+condition:\s+app\.enabled/s, 'local dependency version in Chart.yaml should stay unchanged');
89+
90+
const childChartContent = fs.readFileSync('tests/charts/umbrella-application/charts/app/Chart.yaml', 'utf8');
91+
assert.match(childChartContent, /version:\s+0\.0\.0/, 'child chart version should stay unchanged');
92+
assert.match(childChartContent, /appVersion:\s+"0\.0\.0"/, 'child chart appVersion should stay unchanged');
93+
94+
const childValuesContent = fs.readFileSync('tests/charts/umbrella-application/charts/app/values.yaml', 'utf8');
95+
assert.match(childValuesContent, /registry:\s+ghcr\.io/, 'child image registry should be updated');
96+
assert.match(childValuesContent, /repository:\s+hoverkraft-tech\/ci-github-container\/umbrella-application/, 'child image repository should be updated');
97+
assert.match(childValuesContent, /tag:\s+0\.2\.0/, 'child image tag should be updated');
98+
99+
const chartLockContent = fs.readFileSync('tests/charts/umbrella-application/Chart.lock', 'utf8');
100+
assert.match(chartLockContent, /version:\s+0\.0\.0/, 'local dependency version in Chart.lock should stay unchanged');

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ _Actions dedicated to packaging, validating, and publishing Helm charts for Kube
4848

4949
#### - [Parse chart URI](actions/helm/parse-chart-uri/README.md)
5050

51+
#### - [Update chart values](actions/helm/update-chart-values/README.md)
52+
5153
#### - [Release chart](actions/helm/release-chart/README.md)
5254

5355
#### - [Test chart](actions/helm/test-chart/README.md)

0 commit comments

Comments
 (0)