diff --git a/.github/scripts/exclude_ci_files.txt b/.github/scripts/exclude_ci_files.txt index 476d958b78..8b00f3872b 100644 --- a/.github/scripts/exclude_ci_files.txt +++ b/.github/scripts/exclude_ci_files.txt @@ -46,5 +46,6 @@ .github/workflows/stale.yml .github/workflows/update-docker-images.yml .github/workflows/update-docker-sha.yml +.github/workflows/update-kubernetes-version.yml .github/workflows/updates-notification.yml .github/workflows/version-bump.yml diff --git a/.github/workflows/update-kubernetes-version.yml b/.github/workflows/update-kubernetes-version.yml new file mode 100644 index 0000000000..23b38fdb6b --- /dev/null +++ b/.github/workflows/update-kubernetes-version.yml @@ -0,0 +1,55 @@ +name: Update Kubernetes version in Helm chart +on: + push: + branches: + - main + - release-* + paths: + - tests/Dockerfile + +concurrency: + group: ${{ github.ref_name }}-k8s-version + cancel-in-progress: true + +permissions: + contents: read + +jobs: + update-k8s-version: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Get current k8s version from Kind image + id: k8s-version + run: | + v=$(grep kindest tests/Dockerfile | cut -d ':' -f 2 | cut -d '@' -f 1) + echo "version=${v}" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + + - name: Search for the version in the schema file + id: search + run: | + found="false" + if grep -q ${{ steps.k8s-version.outputs.version }} charts/nginx-ingress/values.schema.json; then + found="true" + fi + echo "found=$found" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + + - name: Replace version in Helm schema file + run: | + sed -i -e "s#/v[0-9]\+\.[0-9]\+\.[0-9]\+/_definitions.json#/${{ steps.k8s-version.outputs.version }}/_definitions.json#" charts/nginx-ingress/values.schema.json + if: ${{ steps.search.outputs.found == 'false' }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 + with: + token: ${{ secrets.NGINX_PAT }} + commit-message: update kubernetes version to ${{ steps.k8s-version.outputs.version }} in helm schema + title: update kubernetes version to ${{ steps.k8s-version.outputs.version }} in helm schema + branch: chore/k8s-${{ steps.k8s-version.outputs.version }} + author: nginx-bot + body: | + This automated PR updates the helm schema k8s version to ${{ steps.k8s-version.outputs.version }}. + if: ${{ steps.search.outputs.found == 'false' }}