Auto Update #10
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: Auto Update | |
| # The 'kubebuilder alpha update 'command requires write access to the repository to create a branch | |
| # with the update files and allow you to open a pull request using the link provided in the issue. | |
| # The branch created will be named in the format kubebuilder-update-from-<from-version>-to-<to-version> by default. | |
| # To protect your codebase, please ensure that you have branch protection rules configured for your | |
| # main branches. This will guarantee that no one can bypass a review and push directly to a branch like 'main'. | |
| permissions: | |
| contents: write | |
| issues: write | |
| models: read | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * 2" # Every Tuesday at 00:00 UTC | |
| jobs: | |
| auto-update: | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Step 1: Checkout the repository. | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| # Step 2: Configure Git to create commits with the GitHub Actions bot. | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Step 3: Set up Go environment. | |
| - name: Set up Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version: stable | |
| # Step 4: Install Kubebuilder. | |
| - name: Install Kubebuilder | |
| run: | | |
| curl -L -o kubebuilder "https://go.kubebuilder.io/dl/latest/$(go env GOOS)/$(go env GOARCH)" | |
| chmod +x kubebuilder | |
| sudo mv kubebuilder /usr/local/bin/ | |
| kubebuilder version | |
| # Step 5: Install Models extension for GitHub CLI | |
| - name: Install/upgrade gh-models extension | |
| run: | | |
| gh extension install github/gh-models --force | |
| gh models --help >/dev/null | |
| # Step 6: Run the Kubebuilder alpha update command. | |
| # More info: https://kubebuilder.io/reference/commands/alpha_update | |
| - name: Run kubebuilder alpha update | |
| # Executes the update command with specified flags. | |
| # --force: Completes the merge even if conflicts occur, leaving conflict markers. | |
| # --push: Automatically pushes the resulting output branch to the 'origin' remote. | |
| # --restore-path: Preserves specified paths (e.g., CI workflow files) when squashing. | |
| # --open-gh-issue: Creates a GitHub Issue with a link for opening a PR for review. | |
| # --use-gh-models: Adds an AI-generated comment to the created Issue with | |
| # a short overview of the scaffold changes and conflict-resolution guidance (If Any). | |
| run: | | |
| kubebuilder alpha update \ | |
| --force \ | |
| --push \ | |
| --restore-path .github/workflows \ | |
| --open-gh-issue \ | |
| --use-gh-models |