|
| 1 | +# AutoUpdate (`autoupdate/v1-alpha`) |
| 2 | + |
| 3 | +Keeping your Kubebuilder project up to date with the latest improvements shouldn’t be a chore. |
| 4 | +With a small amount of setup, you can receive **automatic Pull Request** suggestions whenever a new |
| 5 | +Kubebuilder release is available — keeping your project **maintained, secure, and aligned with ecosystem changes**. |
| 6 | + |
| 7 | +This automation uses the [`kubebuilder alpha update`][alpha-update-command] command with a **3-way merge strategy** to |
| 8 | +refresh your project scaffold, and wraps it in a GitHub Actions workflow that opens an **Issue** with a **Pull Request compare link** so you can create the PR and review it. |
| 9 | + |
| 10 | +## When to Use It |
| 11 | + |
| 12 | +- When you don’t deviate too much from the default scaffold — ensure that you see the note about customization [here](https://book.kubebuilder.io/versions_compatibility_supportability#project-customizations). |
| 13 | +- When you want to reduce the burden of keeping the project updated and well-maintained. |
| 14 | + |
| 15 | +## How to Use It |
| 16 | + |
| 17 | +0 If you want to add the `autoupdate` plugin to your project: |
| 18 | + |
| 19 | +```shell |
| 20 | +kubebuilder edit --plugins="autoupdate.kubebuilder.io/v1-alpha" |
| 21 | +``` |
| 22 | + |
| 23 | +- If you want to create a new project with the `autoupdate` plugin: |
| 24 | + |
| 25 | +```shell |
| 26 | +kubebuilder init --plugins=go/v4,autoupdate/v1-alpha |
| 27 | +``` |
| 28 | + |
| 29 | +## How It Works |
| 30 | + |
| 31 | +This will scaffold and GitHub Actions workflow that runs the [kubebuilder alpha update][alpha-update-command] command. |
| 32 | +Then, whenever a new Kubebuilder release is available, it will open an Issue with a |
| 33 | +Pull Request compare link so you can create the PR and review it, such as: |
| 34 | + |
| 35 | +<img width="638" height="482" alt="Example Issue" src="https://github.com/user-attachments/assets/589fd16b-7709-4cd5-b169-fd53d69790d4" /> |
| 36 | + |
| 37 | +The workflow will check once a week for new releases, and if there are any, it will create an Issue with a Pull Request compare link so you can create the PR and review it. |
| 38 | +The command called by the workflow is: |
| 39 | + |
| 40 | +```shell |
| 41 | + # More info: https://kubebuilder.io/reference/commands/alpha_update |
| 42 | + - name: Run kubebuilder alpha update |
| 43 | + run: | |
| 44 | + # Executes the update command with specified flags. |
| 45 | + # --force: Completes the merge even if conflicts occur, leaving conflict markers. |
| 46 | + # --push: Automatically pushes the resulting output branch to the 'origin' remote. |
| 47 | + # --restore-path: Preserves specified paths (e.g., CI workflow files) when squashing. |
| 48 | + # --open-gh-issue: Creates a GitHub issue with a link to the generated PR for review. |
| 49 | + kubebuilder alpha update \ |
| 50 | + --force \ |
| 51 | + --push \ |
| 52 | + --restore-path .github/workflows \ |
| 53 | + --open-gh-issue |
| 54 | +``` |
| 55 | + |
| 56 | +<aside class="warning"> |
| 57 | +<h1>Protect your branches</h1> |
| 58 | + |
| 59 | +This workflow by default **only** creates and pushes the merged files to a branch |
| 60 | +called `kubebuilder-update-from-<from-version>-to-<to-version>`. |
| 61 | + |
| 62 | +To keep your codebase safe, use branch protection rules to ensure that |
| 63 | +changes aren't pushed or merged without proper review. |
| 64 | + |
| 65 | +</aside> |
| 66 | + |
| 67 | +[alpha-update-command]: ./../../reference/commands/alpha_update.md |
0 commit comments