🔄 synced local 'charts/kong-operator' with remote 'charts/kong-operat… #414
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 | |
| concurrency: | |
| # Queue release runs per branch so duplicate OCI pushes cannot race each other. | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| env: | |
| MISE_VERBOSE: 1 | |
| MISE_DEBUG: 1 | |
| jobs: | |
| release: | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config user.name "$GITHUB_ACTOR" | |
| git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
| - uses: jdx/mise-action@f10502fc09dadecfefb962fff68ce77213930204 # v4.2.2 | |
| - name: Add dependency chart repos | |
| run: | | |
| helm repo add bitnami https://charts.bitnami.com/bitnami | |
| helm repo add kong https://charts.konghq.com | |
| - name: Check existing kong-operator release | |
| id: kong_operator_release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| version="$(awk '$1=="version:" { print $2; exit }' charts/kong-operator/Chart.yaml)" | |
| tag="kong-operator-${version}" | |
| error_file="$(mktemp)" | |
| trap 'rm -f "${error_file}"' EXIT | |
| if gh release view "${tag}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>"${error_file}"; then | |
| already_released=true | |
| elif grep -qE 'release not found|HTTP 404' "${error_file}"; then | |
| already_released=false | |
| else | |
| cat "${error_file}" >&2 | |
| exit 1 | |
| fi | |
| { | |
| echo "version=${version}" | |
| echo "already_released=${already_released}" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Run chart-releaser | |
| id: chart_releaser | |
| uses: helm/chart-releaser-action@cae68fefc6b5f367a0275617c9f83181ba54714f # v1.7.0 | |
| with: | |
| skip_existing: true | |
| env: | |
| CR_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Chart releaser selection | |
| if: ${{ steps.chart_releaser.outputs.changed_charts != '' }} | |
| run: | | |
| echo "Selected charts: ${{ steps.chart_releaser.outputs.changed_charts }}" | |
| echo "Existing GitHub releases are skipped during upload." | |
| - name: Skip existing kong-operator OCI push | |
| if: ${{ contains(steps.chart_releaser.outputs.changed_charts, 'charts/kong-operator') && steps.kong_operator_release.outputs.already_released == 'true' }} | |
| run: | | |
| echo "Skipping OCI push for kong-operator-chart:${{ steps.kong_operator_release.outputs.version }} because this chart release already existed before the workflow started." | |
| - name: Check OCI push preconditions | |
| id: oci_push | |
| env: | |
| PUBLISH_OCI: ${{ contains(steps.chart_releaser.outputs.changed_charts, 'charts/kong-operator') && steps.kong_operator_release.outputs.already_released != 'true' }} | |
| DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_PUSH_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_PUSH_TOKEN_KO_CHART }} | |
| run: | | |
| if [[ "$PUBLISH_OCI" == "true" && -n "$DOCKERHUB_USERNAME" && -n "$DOCKERHUB_TOKEN" ]]; then | |
| echo "should_push=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "should_push=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Login to DockerHub (OCI) | |
| if: ${{ steps.oci_push.outputs.should_push == 'true' }} | |
| env: | |
| DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_PUSH_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_PUSH_TOKEN_KO_CHART }} | |
| 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.oci_push.outputs.should_push == 'true' }} | |
| shell: bash | |
| env: | |
| KONG_OPERATOR_VERSION: ${{ steps.kong_operator_release.outputs.version }} | |
| 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-${KONG_OPERATOR_VERSION}.tgz" oci://registry-1.docker.io/kong |