-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add reusable workflow for Helm Chart #108
Draft
b0l0k
wants to merge
7
commits into
main
Choose a base branch
from
add-reusable-workflow-helm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+328
−6
Draft
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
11f544d
Add reusable workflow for Helm linting & publishing
b0l0k 01e4371
Add semver support on python-app action
b0l0k e66d8ec
Test shared runners for Build and publish Helm Chart
rlaschuk-ledger 03f1d59
fix kubeconform test
b0l0k dfa68a0
allow to use lint & publish separately
b0l0k 47b0c27
helm push ignore if not chart directory
b0l0k 739f8ad
Update _helm_publish.yml
mmejdoub-ledger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: _Build and publish Helm Chart | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
chart-testing-config: | ||
type: string | ||
required: false | ||
default: ".github/ct.yaml" | ||
charts-path: | ||
type: string | ||
required: false | ||
default: "./helm/charts/" | ||
|
||
jobs: | ||
lint-chart: | ||
runs-on: [shared] | ||
steps: | ||
- name: Register dependencies repository | ||
shell: bash | ||
run: | | ||
if [ ! -z "${{ secrets.DEV_CHARTMUSEUM_URL }}" ]; then | ||
helm repo add dev-chartmuseum --username ${{ secrets.DEV_CHARTMUSEUM_USER }} --password ${{ secrets.DEV_CHARTMUSEUM_PASSWORD }} ${{ secrets.DEV_CHARTMUSEUM_URL }} | ||
helm repo update | ||
fi | ||
if [ ! -z "${{ secrets.PROD_CHARTMUSEUM_URL }}" ]; then | ||
helm repo add prd-chartmuseum --username ${{ secrets.PROD_CHARTMUSEUM_USER }} --password ${{ secrets.PROD_CHARTMUSEUM_PASSWORD }} ${{ secrets.PROD_CHARTMUSEUM_URL }} | ||
helm repo update | ||
fi | ||
- name: Run Chart lint | ||
uses: LedgerHQ/actions/helm/lint@add-reusable-workflow-helm | ||
with: | ||
chart-testing-config: ${{inputs.chart-testing-config}} | ||
|
||
kubeconform-chart: | ||
runs-on: [shared] | ||
strategy: | ||
matrix: | ||
k8s: | ||
- v1.23.0 | ||
- v1.24.0 | ||
steps: | ||
- name: Register dependencies repository | ||
shell: bash | ||
run: | | ||
if [ ! -z "${{ secrets.PROD_CHARTMUSEUM_URL }}" ]; then | ||
helm repo add chartmuseum --username ${{ secrets.PROD_CHARTMUSEUM_USER }} --password ${{ secrets.PROD_CHARTMUSEUM_PASSWORD }} ${{ secrets.PROD_CHARTMUSEUM_URL }} | ||
helm repo update | ||
fi | ||
- name: Run Kubeconform | ||
uses: LedgerHQ/actions/helm/conform@add-reusable-workflow-helm | ||
with: | ||
kubernetes-version: ${{ matrix.k8s }} | ||
charts-path: ${{inputs.charts-path}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: _Build and publish Helm Chart | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release: | ||
type: boolean | ||
required: false | ||
default: false | ||
version: | ||
type: string | ||
required: false | ||
chart-testing-config: | ||
type: string | ||
required: false | ||
default: ".github/ct.yaml" | ||
charts-path: | ||
type: string | ||
required: false | ||
default: "./helm/charts/" | ||
|
||
jobs: | ||
lint: | ||
name: "Lint & Kubeconform chart(s)" | ||
uses: LedgerHQ/actions/.github/workflows/_helm_lint.yml@add-reusable-workflow-helm | ||
with: | ||
chart-testing-config: ${{ inputs.chart-testing-config }} | ||
charts-path: ${{ inputs.charts-path }} | ||
secrets: inherit | ||
|
||
publish: | ||
name: "Publish chart(s)" | ||
needs: [lint] | ||
uses: LedgerHQ/actions/.github/workflows/_helm_publish.yml@add-reusable-workflow-helm | ||
with: | ||
charts-path: ${{ inputs.charts-path }} | ||
version: ${{ inputs.version }} | ||
release: ${{ inputs.release }} | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: _Build and publish Helm Chart | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release: | ||
type: boolean | ||
required: false | ||
default: false | ||
version: | ||
type: string | ||
required: false | ||
charts-path: | ||
type: string | ||
required: false | ||
default: "./helm/charts/" | ||
|
||
jobs: | ||
publish-chartmuseum-dev: | ||
name: publish-chartmuseum-dev | ||
environment: chartmuseum-dev | ||
if: inputs.version != '' | ||
runs-on: [shared] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Push chart to chartmuseum-prd repo | ||
uses: LedgerHQ/actions/helm/publish-cm@add-reusable-workflow-helm | ||
with: | ||
charts-path: ${{inputs.charts-path}} | ||
version: ${{ inputs.version }} | ||
chartmuseum-url: ${{ secrets.CHARTMUSEUM_URL }} | ||
chartmuseum-user: ${{ secrets.CHARTMUSEUM_USER }} | ||
chartmuseum-password: ${{ secrets.CHARTMUSEUM_PASSWORD }} | ||
force: true | ||
|
||
publish-chartmuseum-prd: | ||
name: publish-chartmuseum-prd | ||
environment: chartmuseum-prd | ||
if: inputs.version != '' && inputs.release != false | ||
runs-on: [shared] | ||
needs: [publish-chartmuseum-dev] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Push chart to chartmuseum-prd repo | ||
uses: LedgerHQ/actions/helm/publish-cm@add-reusable-workflow-helm | ||
with: | ||
charts-path: ${{inputs.charts-path}} | ||
version: ${{ inputs.version }} | ||
chartmuseum-url: ${{ secrets.CHARTMUSEUM_URL }} | ||
chartmuseum-user: ${{ secrets.CHARTMUSEUM_USER }} | ||
chartmuseum-password: ${{ secrets.CHARTMUSEUM_PASSWORD }} | ||
force: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: "Run Kubeconform" | ||
description: "Run Kubeconform againt specified K8S version." | ||
|
||
inputs: | ||
kubernetes-version: | ||
description: "Specify the kubernetes version that you want to test." | ||
required: true | ||
charts-path: | ||
description: "Specify the path where the charts are located." | ||
required: false | ||
default: "./helm/charts/" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run kubeconform | ||
shell: bash | ||
env: | ||
KUBERNETES_VERSION: ${{ matrix.k8s }} | ||
KUBECONFORM_VERSION: "v0.4.12" | ||
KUBECONFORM_BASE_URL: "https://github.com/yannh/kubeconform/releases/download" | ||
FILENAME_FORMAT: "{kind}-{group}-{version}" | ||
run: | | ||
set -o pipefail | ||
OS=$(uname) | ||
# install kubeconform | ||
curl -sSfL "${KUBECONFORM_BASE_URL}/${KUBECONFORM_VERSION}/kubeconform-${OS}-amd64.tar.gz" | | ||
tar -xzf - kubeconform | ||
# validate changed charts | ||
for chart in ${{ inputs.charts-path }}/*/; do | ||
values=$(echo "${chart}" | sed "s/charts/values/g") | ||
echo "Running kubeconform for this folder: '${chart}'" | ||
|
||
# Test if the directory contains Chart.yaml | ||
if [ ! -f "${chart}/Chart.yaml" ]; then | ||
echo "Chart.yaml not present, skip." | ||
continue | ||
fi | ||
|
||
# Test if the directory respects the convention */charts & */values | ||
if [ ${values} == ${chart} -o ! -d ${values} ]; then | ||
echo "Chart/Values not present, skip." | ||
continue | ||
fi | ||
|
||
helm dep up "${chart}" && | ||
for value in $(find "${values}" -type f -name "*.yaml"); do | ||
echo -e "▶ Validating ${chart} with values from ${value}" | ||
helm template --kube-version "${KUBERNETES_VERSION#v}" -f "${value}" "${chart}" | | ||
./kubeconform -strict -ignore-missing-schemas -exit-on-error \ | ||
-schema-location default -schema-location 'helm/k8s-crds-schemas/{{ .ResourceKind }}{{ .KindSuffix }}.json' \ | ||
-kubernetes-version "${KUBERNETES_VERSION#v}" -summary -verbose -schema-location default | ||
done | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: "Run Helm Chart Testing & Docs" | ||
description: "Run Helm Chart Testing & Docs" | ||
|
||
inputs: | ||
chart-testing-config: | ||
description: "Specify the path where the ct.yaml is located." | ||
required: true | ||
default: ".github/ct.yaml" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up chart-testing | ||
uses: helm/[email protected] | ||
|
||
- name: Run chart-testing (lint) | ||
shell: bash | ||
run: ct lint --config ${{ inputs.chart-testing-config }} --check-version-increment=false | ||
|
||
- name: Run helm-docs | ||
shell: bash | ||
env: | ||
HELM_DOCS_VERSION: "1.11.0" | ||
HELM_DOCS_BASE_URL: "https://github.com/norwoodj/helm-docs/releases/download" | ||
run: | | ||
OS=$(uname) | ||
# install helm-docs | ||
curl -sSfL "${HELM_DOCS_BASE_URL}/v${HELM_DOCS_VERSION}/helm-docs_${HELM_DOCS_VERSION}_${OS}_x86_64.tar.gz" | | ||
tar -xzf - helm-docs | ||
# validate docs | ||
./helm-docs | ||
git diff --exit-code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: "Publish Helm Chart on chart museum" | ||
description: "Publish Helm Chart on chart museum." | ||
|
||
inputs: | ||
version: | ||
description: "Specify the chart version to publish." | ||
required: true | ||
charts-path: | ||
description: "Specify the path where the charts are located." | ||
required: false | ||
default: "./helm/charts/" | ||
chartmuseum-url: | ||
description: "Specify the URL of Chart Museum" | ||
required: true | ||
chartmuseum-user: | ||
description: "Specify the user of Chart Museum" | ||
required: true | ||
chartmuseum-password: | ||
description: "Specify the password of Chart Museum" | ||
required: true | ||
force: | ||
description: "Replace charts if it exists" | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Add chartmuseum helm repo | ||
shell: bash | ||
run: | | ||
if ! helm plugin list | grep -q push; then | ||
helm plugin install https://github.com/chartmuseum/helm-push.git | ||
fi | ||
helm repo add chartmuseum --username ${{ inputs.chartmuseum-user }} --password ${{ inputs.chartmuseum-password }} ${{ inputs.chartmuseum-url }} && | ||
helm repo update | ||
- name: Push chart to chartmuseum repo | ||
shell: bash | ||
run: | | ||
for chart in ${{ inputs.charts-path }}/*/; do | ||
# Test if the directory contains Chart.yaml | ||
if [ ! -f "${chart}/Chart.yaml" ]; then | ||
echo "Chart.yaml not present, skip." | ||
continue | ||
fi | ||
helm cm-push ${{ inputs.force && '-f'}} $chart chartmuseum --version ${{ inputs.version }} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chartmuseum-dev