-
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
Merged
stplasim
merged 6 commits into
main
from
ab-353-github-action-to-setup-helm-chart-with-appversion-for
Mar 5, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce66013
add optional helm version input to action configuration
stplasim 87add6f
add helm chart authentication, versioning, and deployment steps
stplasim 8285c42
update readme to include helm inputs and usage examples
stplasim d6a1aaf
Apply suggestions from code review
stplasim b23b68e
make helm-registry-url a required input
stplasim 0e42f3f
Merge remote-tracking branch 'origin/ab-353-github-action-to-setup-he…
stplasim 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -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" | ||
| required: true | ||
| helm-registry-url: | ||
| description: "The Helm OCI registry URL" | ||
| required: true | ||
| helm-package: | ||
| description: "The Helm package" | ||
| 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 | ||
|
|
||
| - 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 }} | ||
This file contains hidden or 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.
Oh wow, is this really a required step. 🤯
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.
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