Skip to content

Commit

Permalink
feat: check helm chart version action + workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkh committed Jul 28, 2023
1 parent b33b438 commit 367a8d2
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/actions/check-helm-chart-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: check-helm-chart-version
description: Check helm chart version and appVersion in Chart.yaml with package.json version
author: datavisyn

inputs:
package_file:
description: "Path to the package.json file"
default: "./package.json"
required: false
chart_directory:
description: "Helm chart directory where to find the Chart.yaml file"
required: true
runs:
using: "composite"
steps:
- name: Check helm chart version
run: |
export CHART_YAML=$CHART_DIRECTORY/Chart.yaml
export CHART_VERSION=$(yq '.version' < $CHART_YAML)
export CHART_APP_VERSION=$(yq '.appVersion' < $CHART_YAML)
export CHART_IMAGE_TAG=$(yq '.imageTag' < $CHART_DIRECTORY/values.yaml)
export PACKAGE_VERSION=$(jq -r '.version' $PACKAGE_FILE)
export SHOULD_EXIT=0
if [[ $CHART_VERSION != $PACKAGE_VERSION ]]; then
echo "Chart version is not equal to package version."
echo "Chart version: $CHART_VERSION"
echo "Package version: $PACKAGE_VERSION"
echo "---"
export SHOULD_EXIT=1
fi
if [[ $CHART_APP_VERSION != $PACKAGE_VERSION ]]; then
echo "Chart appVersion is not equal to package version."
echo "Chart appVersion: $CHART_APP_VERSION"
echo "Package version: $PACKAGE_VERSION"
echo "---"
export SHOULD_EXIT=1
fi
if [[ $CHART_IMAGE_TAG != v$PACKAGE_VERSION ]]; then
echo "Chart imageTag is not equal to package version."
echo "Chart imageTag: $CHART_IMAGE_TAG"
echo "Package version: v$PACKAGE_VERSION"
echo "---"
export SHOULD_EXIT=1
fi
if [[ $SHOULD_EXIT == 1 ]]; then
echo "Version mismatch. Please update the version in Chart.yaml and values.yaml to match the version in package.json."
echo "Exiting..."
exit 1
fi
shell: bash
env:
PACKAGE_FILE: ${{ inputs.package_file }}
CHART_DIRECTORY: ${{ inputs.chart_directory }}
36 changes: 36 additions & 0 deletions .github/workflows/check-helm-chart-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: check-helm-chart-version

on:
workflow_dispatch:
inputs:
package_file:
description: "Path to the package.json file"
default: "./package.json"
required: false
chart_directory:
description: "Helm chart directory where to find the Chart.yaml file"
required: true

permissions:
id-token: write
contents: read

env:
WORKFLOW_BRANCH: "new_deployment_build-push-helm-chart"

jobs:
check-helm-chart-version:
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/check-helm-chart-version
with:
package_file: ${{ inputs.package_file }}
current_directory: ${{ inputs.chart_directory }}

0 comments on commit 367a8d2

Please sign in to comment.