Update Chart.yaml #40
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
name: Release | |
# on: | |
# push: | |
# tags: | |
# - '*' | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY_URL: registry-1.docker.io | |
REGISTRY_REPO: shalb | |
jobs: | |
release: | |
name: Release helm charts | |
runs-on: ubuntu-latest | |
container: alpine/helm:3.12.0 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set env | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Build and push | |
run: | | |
set -x | |
git config --global --add safe.directory /__w/charts/charts | |
git show --pretty="" --name-only | cut -d"/" -f1 | |
echo ${{ secrets.DOCKERHUB_TOKEN }} | helm registry login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin ${{ env.REGISTRY_URL}} | |
for CHART_NAME in $(git show --pretty="" --name-only | cut -d"/" -f1 | sort | uniq); do | |
VERSION=$(cat ${CHART_NAME}/Chart.yaml | egrep "^version" | cut -d" " -f2) | |
echo "checking if Chart.yaml exists..." | |
set +e | |
if [[ -f ${CHART_NAME}/Chart.yaml ]] || [[ -f ${CHART_NAME}/Chart.yml ]]; then | |
echo "checking if version exists..." | |
helm pull oci://${{ env.REGISTRY_URL}}/${{ env.REGISTRY_REPO}}/${CHART_NAME} --version ${VERSION} && exit 1 | |
set -e | |
echo "build and push" | |
helm package --version ${VERSION} ${CHART_NAME} | |
helm push ${CHART_NAME}-${VERSION}.tgz oci://${{ env.REGISTRY_URL}}/${{ env.REGISTRY_REPO}} | |
fi | |
done |