Skip to content

ci: Revert GitHub Actions workflow for publishing charts (#1076) #29

ci: Revert GitHub Actions workflow for publishing charts (#1076)

ci: Revert GitHub Actions workflow for publishing charts (#1076) #29

name: Release Charts
on:
push:
paths:
- 'charts/**'
- '.github/workflows/publish-charts.yaml'
branches:
- master
jobs:
lint-charts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.5.4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.0
- name: Run chart-testing (lint)
run: |
ct lint --config ct.yaml
test-charts:
needs:
- lint-charts
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.5.0
with:
cluster_name: kind
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.5.4
- name: Install yq
run: |
sudo snap install yq
- name: Install and test Redis Related Helm charts
run: |
kubectl cluster-info --context kind-kind
chart_dirs=("redis-operator" "redis" "redis-cluster" "redis-replication" "redis-sentinel")
for dir in "${chart_dirs[@]}"
do
if [[ -f ./charts/$dir/Chart.yaml ]]; then
helm dependency update ./charts/$dir/
fi
helm install $dir ./charts/$dir/
helm test $dir
done
echo "Listing installed Helm charts..."
release-charts:
runs-on: ubuntu-latest
needs:
- test-charts
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: "${{ github.repository_owner }}/redis-operator"
path: "redis-operator"
fetch-depth: 0
- name: Checkout helm-charts
uses: actions/checkout@v3
with:
repository: "${{ github.repository_owner }}/helm-charts"
# use token for helm-charts repo
token: "${{ secrets.HELM_CHARTER_TOKEN }}"
path: "helm-charts"
fetch-depth: 0
- name: Get chart version
run: |
echo "chart_version=$(echo ${GITHUB_REF##*/v})" >> $GITHUB_ENV
- name: Install Helm
uses: azure/setup-helm@v4.2.0
- name: Make charts
shell: bash
working-directory: redis-operator
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
chart_dirs=("redis-operator" "redis" "redis-cluster" "redis-replication" "redis-sentinel")
for dir in "${chart_dirs[@]}"
do
if [[ -f ./charts/$dir/Chart.yaml ]]; then
helm dependency update ./charts/$dir/
fi
helm package charts/$dir -d .cr-release-packages
done
- name: Install chart-releaser
uses: helm/chart-releaser-action@v1.5.0
with:
install_only: true
# upload charts to helm-charts repos's release
- name: Upload charts
shell: bash
working-directory: redis-operator
run: |
cr upload
env:
# GitHub repository
CR_GIT_REPO: "helm-charts"
# Path to directory with chart packages (default ".cr-release-packages")
CR_PACKAGE_PATH: ".cr-release-packages"
# use token for helm-charts repo
CR_TOKEN: "${{ secrets.HELM_CHARTER_TOKEN }}"
# owner
CR_OWNER: "${{ github.repository_owner }}"
# skip existing charts
CR_SKIP_EXISTING: "true"
# copy artifacts to helm-charts repo, we need those for update index
- name: Copy artifacts
run: |
cp -r redis-operator/.cr-release-packages helm-charts/
- name: Configure Git
working-directory: helm-charts
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# this step will directly push to the main branch, so make sure you have the right permissions
- name: Update index
working-directory: helm-charts
run: |
cr index --push
env:
# GitHub repository
CR_GIT_REPO: "helm-charts"
# The GitHub pages branch (default "gh-pages")
CR_PAGES_BRANCH: "gh-pages"
# Path to directory with chart packages (default ".cr-release-packages")
CR_PACKAGE_PATH: ".cr-release-packages"
# use token for helm-charts repo
CR_TOKEN: "${{ secrets.HELM_CHARTER_TOKEN }}"
# owner
CR_OWNER: "${{ github.repository_owner }}"
# index path
CR_INDEX_PATH: "index.yaml"