-
Notifications
You must be signed in to change notification settings - Fork 0
GitHub action to setup Helm chart with appVersion for deployment #3
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
Changes from 3 commits
ce66013
87add6f
8285c42
d6a1aaf
b23b68e
0e42f3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,76 @@ | ||
| name: 'Deploy Helm chart to Kubernetes' | ||
| description: 'Deploy an application to a Kubernetes cluster using its Helm chart' | ||
| name: "Helm Chart Setup and Deployment" | ||
| description: "Setup a Helm chart, modify its appVersion, and deploy it to a Kubernetes cluster" | ||
|
|
||
| inputs: | ||
| helm-chart-version: | ||
| description: "The Helm chart version to pull" | ||
|
stplasim marked this conversation as resolved.
Outdated
|
||
| required: true | ||
| helm-registry-url: | ||
| description: "The Helm OCI registry URL" | ||
| default: "ghcr.io" | ||
| helm-package: | ||
| description: "The Helm package to pull" | ||
|
stplasim marked this conversation as resolved.
Outdated
|
||
| required: true | ||
| helm-username: | ||
| description: "The username to authenticate with the Helm registry" | ||
| required: true | ||
| helm-password: | ||
| description: "The password to authenticate with the Helm registry" | ||
| required: true | ||
| helm-protocol: | ||
| description: "The protocol for fetching the Helm chart (e.g., oci://). Default is 'oci://'." | ||
| default: "oci://" | ||
| release-name: | ||
| description: 'The name of the Helm release' | ||
| description: "The name of the Helm release" | ||
| required: true | ||
| chart-path: | ||
| description: 'The directory of the Helm chart' | ||
| default: '.' | ||
| values-file: | ||
| description: 'Path to the Helm values file' | ||
| description: "Path to the Helm values file" | ||
| required: true | ||
| image-tag: | ||
| description: 'Tag of the container image' | ||
| default: 'latest' | ||
| description: "Tag of the container image" | ||
| default: "latest" | ||
| timeout: | ||
| description: 'Timeout for the Helm command' | ||
| default: '5m' | ||
| description: "Timeout for the Helm command" | ||
| default: "5m" | ||
| working-directory: | ||
| description: 'The working directory' | ||
| default: '.' | ||
| description: "The working directory" | ||
| default: "." | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Login to Helm registry | ||
| shell: bash | ||
| run: | | ||
| helm registry login ${{ inputs.helm-registry-url }} \ | ||
| -u ${{ inputs.helm-username }} \ | ||
| -p ${{ inputs.helm-password }} | ||
|
|
||
| - name: Pull the Helm chart | ||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| helm pull ${{ inputs.helm-protocol }}${{ inputs.helm-registry-url }}/${{ inputs.helm-package }} \ | ||
| --version ${{ inputs.helm-chart-version }} | ||
|
|
||
| - name: Extract Helm chart | ||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| tar -xzf ${{ inputs.helm-package }}-*.tgz | ||
|
Comment on lines
+56
to
+60
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wow, is this really a required step. 🤯
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need this step because we want to set the app version to the commit hash. If we didn't set this or left it at a fixed value, we could omit this and the pull step and specify the OCI image directly when upgrading. But as I said, without the app version it is relatively difficult to find the deployment again |
||
|
|
||
| - name: Update appVersion in Chart.yaml | ||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| yq -i '.appVersion = "${{ github.sha }}" | .appVersion style="double"' \ | ||
| ${{ inputs.helm-package }}/Chart.yaml | ||
|
|
||
| - name: Deploy Helm chart | ||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| helm upgrade --wait --install ${{ inputs.release-name }} ${{ inputs.chart-path }} \ | ||
| helm upgrade --wait --install ${{ inputs.release-name }} ./${{ inputs.helm-package }} \ | ||
| --values ${{ inputs.values-file }} \ | ||
| --atomic --timeout ${{ inputs.timeout }} \ | ||
| --set image.tag=${{ inputs.image-tag }} | ||
Uh oh!
There was an error while loading. Please reload this page.