Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions actions/helm/prepare-chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- header:start -->
<!-- header:end -->

<!-- badges:start -->
<!-- badges:end -->

<!-- overview:start -->
<!-- overview:end -->

<!-- usage:start -->
<!-- usage:end -->

<!-- inputs:start -->
<!-- inputs:end -->

<!-- secrets:start -->
<!-- secrets:end -->

<!-- outputs:start -->
<!-- outputs:end -->

<!-- examples:start -->
<!-- examples:end -->

<!--
// jscpd:ignore-start
-->

<!-- contributing:start -->
<!-- contributing:end -->

<!-- security:start -->
<!-- security:end -->

<!-- license:start -->
<!-- license:end -->

<!-- generated:start -->
<!-- generated:end -->

<!--
// jscpd:ignore-start
-->
84 changes: 84 additions & 0 deletions actions/helm/prepare-chart/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: "Prepare Helm Chart"
description: |
Add Helm repositories and build chart dependencies
for all charts found under a path.
author: hoverkraft
branding:
icon: package
color: blue

inputs:
path:
description: "Path containing the chart(s) to prepare"
required: true
helm-repositories:
description: |
List of Helm repositories to add before building chart dependencies.
See https://helm.sh/docs/helm/helm_repo_add/.
required: false

runs:
using: "composite"
steps:
- name: Add Helm repositories
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
INPUT_HELM_REPOSITORIES: ${{ inputs.helm-repositories }}
with:
script: |
const repositories = (process.env.INPUT_HELM_REPOSITORIES ?? '')
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line.length > 0);

for (const repository of repositories) {
await exec.exec('helm', [
'repo',
'add',
...repository.split(/\s+/),
]);
}

- name: Build chart dependencies
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
INPUT_PATH: ${{ inputs.path }}
with:
script: |
const path = require('node:path');

const chartPath = process.env.INPUT_PATH;
if (!chartPath) {
core.setFailed('"path" input is missing');
return;
}

core.info('Building charts dependencies');

const chartRootDir = path.resolve(
process.env.GITHUB_WORKSPACE ?? '.',
chartPath,
);
const chartFiles = [];
const globber = await glob.create(
`${chartPath}/**/Chart.yaml`,
{ followSymbolicLinks: false },
);

for await (const chartFile of globber.globGenerator()) {
chartFiles.push(chartFile);
}

if (chartFiles.length === 0) {
core.info(`No charts found in ${chartRootDir}`);
return;
}

chartFiles.sort();

for (const chartFile of chartFiles) {
const chartDir = path.dirname(chartFile);
core.info(`Building dependencies for ${chartDir}`);
await exec.exec('helm', ['dependency', 'build', chartDir]);
}
45 changes: 6 additions & 39 deletions actions/helm/release-chart/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,45 +252,12 @@ runs:

- uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0

- shell: bash
env:
INPUT_HELM_REPOSITORIES: ${{ inputs.helm-repositories }}
run: |
# For each line in the input, add the Helm repository
printf '%s\n' "$INPUT_HELM_REPOSITORIES" | while IFS= read -r line; do
if [ -z "$line" ]; then
continue
fi

# shellcheck disable=SC2086
helm repo add $line
done

- shell: bash
env:
INPUT_PATH: ${{ inputs.path }}
run: |
echo "Building charts dependencies"

CHART_ROOT_DIR="$(pwd)/$INPUT_PATH"
CHART_FILES=$(find "$CHART_ROOT_DIR" -name "Chart.yaml")

# If no files found, exit
if [ -z "$CHART_FILES" ]; then
echo "No charts found in $CHART_ROOT_DIR"
exit 0
fi

# For each chart, build dependencies
for chart in $CHART_FILES; do
if [ ! -f "$chart" ]; then
continue
fi

CHART_DIR=$(dirname "$chart")
echo "Building dependencies for $CHART_DIR"
helm dependency build "$CHART_DIR"
done
- name: Prepare chart dependencies
uses: ./actions/helm/prepare-chart
with:
path: ${{ inputs.path }}
helm-repositories: >-
${{ inputs.helm-repositories }}

- id: chart-releaser
uses: appany/helm-oci-chart-releaser@d94988c92bed2e09c6113981f15f8bb495d10943 # v0.5.0
Expand Down
Loading
Loading