Skip to content

Auto Update

Auto Update #10

Workflow file for this run

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: {}
on:
workflow_dispatch:
# schedule:
# - cron: "0 0 * * 2" # Every Tuesday at 00:00 UTC
jobs:
auto-update:
permissions:
contents: write # Create and push the update branch
issues: write # Create GitHub Issue with PR link
actions: write # Required to push branches containing workflow file changes
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Checkout the repository.
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: true
# 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"
# Set up Go environment.
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version: stable
# 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
# 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.
#
# WARNING: This workflow does not use GitHub Models AI summary by default.
# To enable AI-generated summaries in GitHub issues, you need permissions to use GitHub Models.
# If you have the required permissions, re-run:
# kubebuilder edit --plugins="autoupdate/v1-alpha" --use-gh-models
run: |
kubebuilder alpha update \
--from-branch ${{ github.ref_name }} \
--force \
--restore-path .github/workflows \
--merge-message "chore: update kubebuilder scaffold" \
--conflict-message "chore: update with conflicts - review needed"
- name: Push update branch
run: |
BRANCH_NAME=$(git branch --list 'kubebuilder-update-from-*' | sed 's/^[* ]*//' | head -1)
if [ -n "$BRANCH_NAME" ]; then
git push origin "$BRANCH_NAME" --force
fi