-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GH Action to build and push a helm chart
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 deletions.
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,72 @@ | ||
name: build-push-helm-chart | ||
description: Build helm chart and push it to ChartMuseum | ||
author: datavisyn | ||
|
||
inputs: | ||
chart_repository_url: | ||
description: "Helm chart repository URL where to push the chart" | ||
required: true | ||
chart_repository_username: | ||
description: "Helm chart repository username" | ||
required: true | ||
chart_repository_password: | ||
description: "Helm chart repository password" | ||
required: true | ||
current_directory: | ||
description: "Current directory for building the helm chart" | ||
required: true | ||
chart_version: | ||
description: "The version is used as chart version and application version. Use semantic versioning." | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: "v3.12.2" | ||
id: install | ||
- name: Print helm version | ||
run: | | ||
helm version | ||
shell: bash | ||
- name: Set up helm chart repository | ||
run: | | ||
helm repo add datavisyn $CHART_REPOSITORY_URL --username $CHART_REPOSITORY_USERNAME --password $CHART_REPOSITORY_PASSWORD | ||
helm repo update | ||
env: | ||
CHART_REPOSITORY_URL: ${{ inputs.chart_repository_url }} | ||
CHART_REPOSITORY_USERNAME: ${{ inputs.chart_repository_username }} | ||
CHART_REPOSITORY_PASSWORD: ${{ inputs.chart_repository_password }} | ||
shell: bash | ||
- name: Inspect and lint helm chart | ||
run: | | ||
cd $CURRENT_DIRECTORY | ||
helm inspect chart . | ||
helm lint | ||
env: | ||
CURRENT_DIRECTORY: ${{ inputs.current_directory }} | ||
shell: bash | ||
- name: Build helm chart | ||
run: | | ||
cd $CURRENT_DIRECTORY | ||
helm dependency update | ||
helm package . --version $CHART_VERSION --app-version $CHART_VERSION --destination $CURRENT_DIRECTORY | ||
env: | ||
CURRENT_DIRECTORY: ${{ inputs.current_directory }} | ||
shell: bash | ||
- name: Push helm chart | ||
run: | | ||
cd $CURRENT_DIRECTORY | ||
helm push *.tgz datavisyn | ||
env: | ||
CURRENT_DIRECTORY: ${{ inputs.current_directory }} | ||
shell: bash | ||
- name: Remove helm chart | ||
run: | | ||
cd $CURRENT_DIRECTORY | ||
rm *.tgz | ||
env: | ||
CURRENT_DIRECTORY: ${{ inputs.current_directory }} | ||
shell: bash | ||
|
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-push-helm-chart | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
DV_CHARTMUSEUM_URL: | ||
required: false | ||
DV_CHARTMUSEUM_USERNAME: | ||
required: true | ||
DV_CHARTMUSEUM_PASSWORD: | ||
required: true | ||
inputs: | ||
current_directory: | ||
description: "Current directory for building the helm chart" | ||
required: true | ||
type: string | ||
chart_version: | ||
description: "Helm chart version is used as chart version and application version. Use semantic versioning." | ||
required: true | ||
type: string | ||
chart_repository_url: | ||
description: "Helm chart repository URL where to push the chart" | ||
required: false | ||
type: string | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
WORKFLOW_BRANCH: "new_deploymentnew_deployment_build-push-helm-chart" | ||
|
||
jobs: | ||
build: | ||
concurrency: | ||
group: "${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.chart_repository_url }}" | ||
cancel-in-progress: true | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
# checkout specific source repository | ||
- uses: actions/checkout@v3 | ||
# checkout this workflow repository to get actions | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: datavisyn/github-workflows | ||
ref: ${{ env.WORKFLOW_BRANCH }} | ||
path: ./tmp/github-workflows | ||
- uses: ./tmp/github-workflows/.github/actions/build-push-helm-chart | ||
with: | ||
chart_repository_url: ${{ inputs.chart_repository_url || secrets.DV_CHARTMUSEUM_URL }} | ||
chart_repository_username: ${{ secrets.DV_CHARTMUSEUM_USERNAME }} | ||
chart_repository_password: ${{ secrets.DV_CHARTMUSEUM_PASSWORD }} | ||
current_directory: ${{ inputs.current_directory }} | ||
chart_version: ${{ inputs.chart_version }} |