Skip to content

Commit

Permalink
Add parameter for Helm publish version (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 authored Apr 30, 2024
1 parent 81553c0 commit befee5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
31 changes: 11 additions & 20 deletions .github/workflows/helm-multi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ on:
required: false
default: ".github/lint-config.yaml"
type: string
version:
description: "Version for helm chart"
required: false
default: ${{ github.ref_name }}
type: string

secrets:
github-username:
Expand All @@ -56,27 +61,21 @@ jobs:
uses: bakdata/ci-templates/actions/[email protected]
with:
lint-config-path: "${{ inputs.lint-config-path }}"
ref: ${{ github.ref_name }}

update-version:
runs-on: ubuntu-22.04
outputs:
singlechart: ${{ steps.step2.outputs.singlechart }}
needs: [helm-lint]
env:
current-ref: ${{ github.ref_name }}
CHARTS: ${{ inputs.subdirs }}

steps:
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
with:
ref: ${{ env.current-ref }}

- name: Verify if have a single or multiple chart(s)
id: step2
run: |
charts="${{ env.CHARTS }}"
charts="${{ inputs.subdirs }}"
charts_without_brackets="${charts:1:-1}"
charts_without_brackets_and_quotation="${charts_without_brackets//\'/}"
Expand All @@ -94,38 +93,33 @@ jobs:
subdir: ${{ fromJson(inputs.subdirs) }}
runs-on: ubuntu-22.04
needs: [update-version]
env:
charts-subdir: "${{ matrix.subdir }}"
current-ref: ${{ github.ref_name }}

steps:
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
with:
ref: ${{ env.current-ref }}

- name: Bump Chart version
run: |
sudo add-apt-repository ppa:rmescandon/yq
sudo apt update
sudo apt install yq -y
yq e -i '.version = "${{ env.current-ref }}"' "./${{ env.charts-subdir }}/Chart.yaml"
yq e -i '.version = "${{ inputs.version }}"' "./${{ matrix.subdir }}/Chart.yaml"
shell: bash
working-directory: ${{ inputs.charts-path }}

- name: Prepare artifacts
run: |
mkdir -p ../${{ inputs.artifact-dir }}/${{ env.charts-subdir }}
helm package ${{ env.charts-subdir }} -d ../${{ inputs.artifact-dir }}/${{ env.charts-subdir }}
mkdir -p ../${{ inputs.artifact-dir }}/${{ matrix.subdir }}
helm package ${{ matrix.subdir }} -d ../${{ inputs.artifact-dir }}/${{ matrix.subdir }}
shell: bash
working-directory: ${{ inputs.charts-path }}

- name: Upload artifacts with action/upload as multi chart
if: ${{ needs.update-version.outputs.singlechart == 'false' }}
uses: actions/[email protected]
with:
name: ${{ env.charts-subdir }}
path: ${{ inputs.artifact-dir }}/${{ env.charts-subdir }}
name: ${{ matrix.subdir }}
path: ${{ inputs.artifact-dir }}/${{ matrix.subdir }}
retention-days: 1

- name: Upload artifacts with action/upload as single chart
Expand All @@ -138,9 +132,6 @@ jobs:
publish-artifacts:
runs-on: ubuntu-22.04
needs: [package-new-artifacts, update-version]
env:
artifact-dir: "${{ inputs.artifact-dir }}"
charts-path: "${{ inputs.artifact-dir }}"

steps:
- name: Check out branch containing the artifatcs and the index.yaml file
Expand Down
1 change: 1 addition & 0 deletions docs/workflows/helm-multi-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
| helm-version | string | false | `"v3.10.1"` | The Helm version. |
| lint-config-path | string | false | `".github/lint-config.yaml"` | The path to the lint configuration file (See https://github.com/helm/chart-testing/blob/main/pkg/config/test_config.yaml). |
| subdirs | string | true | | List of subdir to consider |
| version | string | false | `"${{ github.ref_name }}"` | Version for helm chart |

<!-- AUTO-DOC-INPUT:END -->

Expand Down

0 comments on commit befee5a

Please sign in to comment.