Skip to content

Commit

Permalink
cherry pick: automate kindest/node versions (#4798) (#4812)
Browse files Browse the repository at this point in the history
* automate kindest/node versions (#4798)

* automate kindest/node versions

* fix typo

* test github action

* undo temporary test

* exclude versions not in the form vX.Y.Z, eg alpha versions

* update k8s_latest origin

* trim the version from the start of the string

* skip pr for get id token step (#4813)
  • Loading branch information
j1m-ryan committed Dec 18, 2023
1 parent b048376 commit 5e571ed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-plus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
script: |
let id_token = await core.getIDToken()
core.setOutput('id_token', id_token)
if: ${{ github.event_name != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') }}

- name: Login to NGINX Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
outputs:
go_path: ${{ steps.vars.outputs.go_path }}
k8s_latest: ${{ steps.vars.outputs.k8s_latest }}
latest_kindest_node_versions: ${{steps.vars.outputs.latest_kindest_node_versions}}
chart_version: ${{ steps.vars.outputs.chart_version }}
steps:
- name: Checkout Repository
Expand All @@ -45,9 +46,31 @@ jobs:
- name: Output Variables
id: vars
run: |
echo "k8s_latest=$(grep -m1 'FROM kindest/node' <tests/Dockerfile | awk -F'[:v]' '{print $3}')" >> $GITHUB_OUTPUT
kindest_latest=$(curl -s "https://hub.docker.com/v2/repositories/kindest/node/tags" \
| grep -o '"name": *"[^"]*' \
| grep -o '[^"]*$' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -rV \
| head -n 1 \
| sed 's/^.\{1\}//' \
| tr -d '\n')
echo "k8s_latest=$kindest_latest" >> $GITHUB_OUTPUT
echo "chart_version=$(yq '.version' <charts/nginx-ingress/Chart.yaml)" >> $GITHUB_OUTPUT
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
kindest_versions=$(curl -s "https://hub.docker.com/v2/repositories/kindest/node/tags" \
| grep -o '"name": *"[^"]*' \
| grep -o '[^"]*$' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -rV \
| awk -F. '!seen[$1"."$2]++' \
| head -n 7 \
| sort -V \
| sed 's/v//g' \
| sed 's/^/\\\"/' \
| sed 's/$/\\\",/' \
| tr '\n' ' ' \
| sed 's/, $//')
echo "latest_kindest_node_versions=$kindest_versions" >> $GITHUB_OUTPUT
- name: Check if go.mod and go.sum are up to date
run: go mod tidy && git diff --exit-code -- go.mod go.sum
Expand Down Expand Up @@ -279,7 +302,7 @@ jobs:
{\"image\": \"debian-plus-nap\", \"marker\": \"dos_learning\"}], \
\"k8s\": [\"${{ needs.checks.outputs.k8s_latest }}\"]}" >> $GITHUB_OUTPUT
else
echo "matrix={\"k8s\": [\"1.22.17\", \"1.23.17\", \"1.24.15\", \"1.25.11\", \"1.26.6\", \"1.27.3\", \"${{ needs.checks.outputs.k8s_latest }}\"], \
echo "matrix={\"k8s\": [${{ needs.checks.outputs.latest_kindest_node_versions }}], \
\"images\": [{\"image\": \"debian\"}, {\"image\": \"debian-plus\"}]}" >> $GITHUB_OUTPUT
fi
Expand Down

0 comments on commit 5e571ed

Please sign in to comment.