Skip to content

Charts: add registry templating to support Elemental airgap scenarios #1319

Charts: add registry templating to support Elemental airgap scenarios

Charts: add registry templating to support Elemental airgap scenarios #1319

Workflow file for this run

name: Build and publish chart
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
jobs:
chart:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install yq
uses: mikefarah/[email protected]
- name: Build chart for CI
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
make chart
- name: Build chart for release
if: startsWith(github.ref, 'refs/tags/')
run: |
REGISTRY_URL=quay.io/costoolkit REPO=elemental-operator REPO_SEEDIMAGE=elemental-seedimage TAG=${GITHUB_REF##*/} make chart
- name: Publish chart to release
uses: fnkr/github-action-ghr@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GHR_COMPRESS: tgz
GHR_PATH: build/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHR_REPLACE: true
- name: Install Helm
if: startsWith(github.ref, 'refs/tags/')
uses: azure/setup-helm@v1
with:
version: v3.7.1
- name: Set chart output
id: chart
run: |
CHART=$(find . -type f -name "elemental-operator-[1-9]*.tgz" -print)
echo "chart_name=$CHART" >> $GITHUB_OUTPUT
- name: Test chart values
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
REGISTRY_URL=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .registry_url)
REPO=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.repository)
if [ "$REGISTRY_URL" != "quay.io/coostoolkit" ]; then
echo "registry_url on the built chart is not the expected value"
echo "Expected quay.io/coostoolkit but got $REGISTRY_URL"
fi
if [ "$REPO" != "elemental-operator-ci" ];then
echo "REPO on the built chart is not the expected value"
echo "Expected elemental-operator-ci but got $REPO"
exit 1
fi
- name: Test release chart values
if: startsWith(github.ref, 'refs/tags/')
run: |
REGISTRY_URL=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .registry_url))
REPO=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.repository)
TAG=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.tag)
if [ "$REGISTRY_URL" != "quay.io/coostoolkit" ]; then
echo "registry_url on the built chart is not the expected value"
echo "Expected quay.io/coostoolkit but got $REGISTRY_URL"
fi
if [ "$REPO" != "elemental-operator" ];then
echo "REPO on the built chart is not the expected value"
echo "Expected elemental-operator but got $REPO"
exit 1
fi
if [ "$TAG" != "${GITHUB_REF##*/}" ];then
echo "TAG on the built chart is not the expected value"
echo "Expected ${GITHUB_REF##*/} but got $TAG"
exit 1
fi
- name: Build and push index
if: startsWith(github.ref, 'refs/tags/')
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git checkout gh-pages
rm index.yaml
helm repo index --url https://rancher.github.io/elemental-operator .
git add index.yaml build/ -f
git commit -m "Updating helm repo to main commit ${{ github.sha }}"
git push --set-upstream origin gh-pages