🔄 synced local 'charts/kong-operator' with remote 'charts/kong-operat… #298
This file contains hidden or 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 Charts | |
on: | |
push: | |
branches: | |
- main | |
- release/kong-2.x | |
permissions: | |
contents: read | |
jobs: | |
release: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_PUSH_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_PUSH_TOKEN_KO_CHART }} | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
with: | |
egress-policy: audit | |
- name: Checkout | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
# See https://github.com/helm/chart-releaser-action/issues/6 | |
- name: Set up Helm | |
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1 | |
- name: Add dependency chart repos | |
run: | | |
helm repo add bitnami https://charts.bitnami.com/bitnami | |
helm repo add kong https://charts.konghq.com | |
- name: Run chart-releaser | |
uses: helm/chart-releaser-action@cae68fefc6b5f367a0275617c9f83181ba54714f # v1.7.0 | |
env: | |
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CR_SKIP_EXISTING: true | |
# Publish kong-operator chart to DockerHub (OCI) when its version changes | |
- name: Determine if kong-operator chart version changed | |
id: kong_operator_oci | |
shell: bash | |
run: | | |
set -euo pipefail | |
NEW_VERSION=$(grep -E '^version:' "charts/kong-operator/Chart.yaml" | awk '{print $2}') | |
SHA="${{ github.event.before }}" | |
if git show "$SHA:charts/kong-operator/Chart.yaml" >/dev/null 2>&1; then | |
OLD_VERSION=$(git show "$SHA:charts/kong-operator/Chart.yaml" | grep -E '^version:' | awk '{print $2}') | |
else | |
OLD_VERSION="" | |
fi | |
echo "new=${NEW_VERSION} old=${OLD_VERSION}" | |
if [ -n "${NEW_VERSION}" ] && [ "${NEW_VERSION}" != "${OLD_VERSION}" ]; then | |
echo "publish_oci=true" >> "$GITHUB_OUTPUT" | |
echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" | |
else | |
echo "publish_oci=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Login to DockerHub (OCI) | |
if: ${{ steps.kong_operator_oci.outputs.publish_oci == 'true' && env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }} | |
env: | |
DOCKERHUB_USERNAME: ${{ env.DOCKERHUB_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ env.DOCKERHUB_TOKEN }} | |
run: | | |
helm registry login -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_TOKEN" registry-1.docker.io | |
- name: Prepare and push kong-operator-chart to DockerHub (OCI) | |
if: ${{ steps.kong_operator_oci.outputs.publish_oci == 'true' && env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }} | |
shell: bash | |
run: | | |
set -euo pipefail | |
WORKDIR="$(mktemp -d)" | |
cp -a charts/kong-operator "${WORKDIR}/kong-operator-chart" | |
# Rename chart to kong-operator-chart (only top-level name) | |
sed -i -E 's/^name:[[:space:]]*kong-operator$/name: kong-operator-chart/' "${WORKDIR}/kong-operator-chart/Chart.yaml" | |
echo "Prepared chart at: ${WORKDIR}/kong-operator-chart" | |
grep -E '^name:' "${WORKDIR}/kong-operator-chart/Chart.yaml" | |
# Package and push to kong/kong-operator-chart | |
helm package "${WORKDIR}/kong-operator-chart" | |
helm push "kong-operator-chart-${{ steps.kong_operator_oci.outputs.version }}.tgz" oci://registry-1.docker.io/kong |