Skip to content

Commit 43bc515

Browse files
authored
feat: output redered target chart template (#156)
* feat: output redered target chart template * feat: build action
1 parent dc631c1 commit 43bc515

5 files changed

Lines changed: 40 additions & 1 deletion

File tree

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ inputs:
4343
runs:
4444
using: 'node20'
4545
main: 'dist/index.js'
46+
47+
outputs:
48+
changed:
49+
description: 'Whether the charts are different'
50+
diff:
51+
description: 'The diff between the charts'
52+
targetTemplate:
53+
description: 'The target chart rendered with the target values'

dist/index.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/action.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,16 @@ export const action = async (
5454
}
5555

5656
output.setDiff(result.stdout)
57+
58+
const targetTemplate = await getExecOutput(
59+
'helm',
60+
['template', targetChartPath, '--values', targetValues],
61+
{
62+
ignoreReturnCode: true
63+
}
64+
)
65+
66+
if (targetTemplate.exitCode === 0) {
67+
output.setTargetTemplate(targetTemplate.stdout)
68+
}
5769
}

src/output.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ export class Output {
3434
this.set('diff', diff)
3535
this.set('changed', 'true')
3636
}
37+
38+
setTargetTemplate(targetTemplate: string): void {
39+
if (this.input.asMarkdown) {
40+
targetTemplate = `\`\`\`yaml\n${targetTemplate}\n\`\`\``
41+
}
42+
this.set('targetTemplate', targetTemplate)
43+
}
3744
}

0 commit comments

Comments
 (0)