Skip to content

Publish Helm Chart main by @liyaka #11

Publish Helm Chart main by @liyaka

Publish Helm Chart main by @liyaka #11

name: Publish Helm Chart
run-name: "Publish Helm Chart ${{ github.ref_name }} by @${{ github.actor }}"
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- "charts/**"
env:
BASE_VERSION: "1.0"
jobs:
set-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Set version
id: version
run: |
BRANCH_NAME="${{ github.ref_name }}"
if [[ "${BRANCH_NAME}" == "main" ]]
then
echo 'version=${{env.BASE_VERSION}}.${{ github.run_number }}' | tee -a $GITHUB_OUTPUT
else
# Normalize branch name
fixedBranchName=$(echo "${BRANCH_NAME}" | sed 's/origin\///; s/\//-/g; s/_/-/g; s/.*/\L&/')
if [ ${#fixedBranchName} -gt 21 ]; then
fixedBranchName="${fixedBranchName:0:20}"
# remove dash at the end
while [ "${fixedBranchName: -1}" = "-" ]; do
fixedBranchName="${fixedBranchName%?}"
done
fi
VERSION="${{env.BASE_VERSION}}-${fixedBranchName}.${{ github.run_number }}"
echo "version=${VERSION}" | tee -a $GITHUB_OUTPUT
fi
publish-helm-chart:
needs:
- set-version
runs-on: ubuntu-latest
env:
VERSION_NAME: ${{ needs.set-version.outputs.version }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Run lint on Helm chart
run: |
set -e
cd charts/public-test
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency build
helm lint --values values.yaml .
cd -
- name: Package helm chart
run: |
mkdir -p .cr-release-packages
cd .cr-release-packages
helm package --version ${{env.VERSION_NAME}} ../charts/public-test/
cd -
- name: Configure Git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
- name: Run chart-releaser
uses: helm/[email protected]
# with:
# skip_packaging: true
# skip_existing: true
# packages_with_index: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Summary
run: |
echo "Helm chart is published, version is : ${{env.VERSION_NAME}}" >> $GITHUB_STEP_SUMMARY