update-k3s #110
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: update-k3s | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 4 * * 0" # https://crontab.guru/#0_4_*_*_0 - “At 04:00 on Sunday.” | |
| env: | |
| KUSTOMIZE_VER: 5.5.0 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| patch-k3s-if-new-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Prepare Kustomize | |
| run: | | |
| echo "before" | |
| curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VER}/kustomize_v${KUSTOMIZE_VER}_linux_amd64.tar.gz -o kustomize.tar.gz | |
| tar -xvzf kustomize.tar.gz && chmod +x ./kustomize | |
| rm kustomize.tar.gz | |
| ./kustomize version | |
| - name: Check for updates | |
| id: update | |
| run: | | |
| VERSION="$(curl -s https://api.github.com/repos/k3s-io/k3s/releases/latest | jq '.tag_name')" | |
| echo "k3s_version=$VERSION" | |
| echo "k3s_version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: "Patch" | |
| run: | | |
| rm -f kustomization.yaml | |
| rm -f patch.yaml | |
| ./kustomize create | |
| cat <<EOF > patch.yaml | |
| - op: replace | |
| path: /spec/version | |
| value: ${{ steps.update.outputs.k3s_version }} | |
| EOF | |
| ./kustomize edit add resource ./deployments/k3s-system-upgrade/upgrade-plan.yaml | |
| ./kustomize edit add patch --kind Plan --path patch.yaml | |
| ./kustomize build . > x.yaml | |
| echo "---------------------------------" | |
| cat kustomization.yaml | |
| echo "---------------------------------" | |
| cat patch.yaml | |
| echo "---------------------------------" | |
| cat x.yaml | |
| echo "---------------------------------" | |
| mv x.yaml ./deployments/k3s-system-upgrade/upgrade-plan.yaml | |
| rm kustomization.yaml | |
| rm patch.yaml | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: update-k3s | |
| commit-message: Update to ${{ steps.update.outputs.k3s_version }} | |
| title: Update to ${{ steps.update.outputs.k3s_version }} | |
| body: | | |
| ${{ steps.update.outputs.k3s_version }} |