mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 00:27:04 +02:00
feat: Create a custom action to verify chart version
This commit is contained in:
parent
c598d8a00a
commit
b4b335ca6e
14 changed files with 25241 additions and 51 deletions
|
@ -1,4 +1,9 @@
|
|||
# See https://pre-commit.com for more information
|
||||
exclude: |
|
||||
(?x)^(
|
||||
.github\/actions\/.*\/dist\/.*
|
||||
)$
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.0.1
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env zx
|
||||
import 'zx/globals'
|
||||
const chart = argv["_"][0]
|
||||
|
||||
argv.debug ? $.verbose = true : $.verbose = false
|
||||
|
||||
if (chart == undefined) {
|
||||
console.log(chalk.redBright(`ERROR: `) + `No chart provided to validate!`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const defaultBranch = argv.default_branch || await $`git remote show origin | awk '/HEAD branch/ {print $NF}'`
|
||||
const chartYamlPath = `${chart}/Chart.yaml`
|
||||
|
||||
if (!await fs.pathExists(chartYamlPath)) {
|
||||
console.log(chalk.redBright(`ERROR: `) + `${chartYamlPath} does not exist!`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const getOriginalChartYamlProcessOutput = await $`git show origin/${defaultBranch}:./${chartYamlPath}`
|
||||
const originalChartYamlContent = Buffer.from(getOriginalChartYamlProcessOutput.stdout, 'utf-8').toString();
|
||||
const originalChartYaml = await YAML.parse(originalChartYamlContent)
|
||||
echo `Original version: ${originalChartYaml.version}`
|
||||
|
||||
const updatedChartYamlContent = await fs.readFile(chartYamlPath, 'utf8')
|
||||
const updatedChartYaml = await YAML.parse(updatedChartYamlContent)
|
||||
if (!updatedChartYaml.version) {
|
||||
console.log(chalk.redBright(`ERROR: `) + `${chartYamlPath} does not contain a version!`)
|
||||
process.exit(1)
|
||||
}
|
||||
echo `New version: ${updatedChartYaml.version}`
|
||||
|
||||
if (updatedChartYaml.version == originalChartYaml.version) {
|
||||
console.log(chalk.redBright(`ERROR: `) + `Chart version has not been updated!`)
|
||||
process.exit(1)
|
||||
} else {
|
||||
console.log(chalk.greenBright(`OK: `) + `Chart version has been updated!`)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue