update k8s #365
This file contains 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: update k8s | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Get latest kubernetes version | |
run: | | |
NEW_K8S_VERSION=$( | |
curl --silent -L https://api.github.com/repos/kubernetes/kubernetes/releases | | |
jq -r ".[] | .tag_name" | | |
grep -i -w -o 'v[0-9]*\.[0-9]*\.[0-9]*$' | | |
sed "s/v//" | sort --version-sort | tail -n 1 | |
) | |
[[ -z "$NEW_K8S_VERSION" ]] && { echo "Failed to get latest kubernetes version" ; exit 1; } | |
echo "NEW_VERSION=$NEW_K8S_VERSION" >> "$GITHUB_ENV" | |
OLD_K8S_VERSION=$( | |
grep -i -w -E "kubernetesVersion.*[0-9].*" build.sbt | | |
sed -E "s/.*kubernetesVersion\s*:=\s*\"(.+)\"/\1/" | |
) | |
[[ -z "$OLD_K8S_VERSION" ]] && { echo "Failed to get the kubernetes version of current build" ; exit 1; } | |
echo "OLD_VERSION=$OLD_K8S_VERSION" >> "$GITHUB_ENV" | |
- | |
name: Update to the latest kubernetes version | |
run: | | |
sed -i -E "s/(kubernetesVersion\s*:=\s*).*\"/\1\"${{ env.NEW_VERSION }}\"/" build.sbt | |
sed -i "s/${{ env.OLD_VERSION }}/${{ env.NEW_VERSION }}/g" README.md | |
- | |
name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.UPDATE_TOKEN }} | |
commit-message: Update kubernetes | |
committer: GitHub <noreply@github.com> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
signoff: false | |
branch: update/kubernetes | |
delete-branch: true | |
title: 'Update kubernetes version' | |
body: | | |
Updated kubernetes from ${{ env.OLD_VERSION }} to ${{ env.NEW_VERSION }} | |
labels: | | |
dependencies | |
automated |