Skip to content

✨ scaffold(v4): add Alpha Update workflow to scaffold #5011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vitorfloriano
Copy link
Contributor

@vitorfloriano vitorfloriano commented Aug 15, 2025

This PR adds the Alpha Update workflow to the .github/workflows directory on the initial project scaffold.

The workflow:

  1. Checks out the project.
  2. Performs an update using the kubebuilder alpha update command
  3. Pushes the changes to a new branch
  4. Creates an Issue with a link for opening a PR using the new branch

The template:

name: Alpha Update
permissions:
  contents: write
  issues: write

on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * 2" # Every Tuesday at 00:00 UTC

jobs:
  alpha-update:
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        fetch-depth: 0
    
    - name: Configure Git
      run: |
        git config --global user.name "github-actions[bot]"
        git config --global user.email "github-actions[bot]@users.noreply.github.com"
    
    - name: Set up Go
      uses: actions/setup-go@v5
      with:
        go-version: stable

    - 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

    - name: Run kubebuilder alpha update
      run: |
        kubebuilder alpha update \
          --force \
          --squash \
          --preserve-path .github/workflows \
          --open-gh-issue

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 15, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vitorfloriano
Once this PR has been reviewed and has the lgtm label, please assign camilamacedo86 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 15, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @vitorfloriano. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

--squash \
--preserve-path .github/workflows \
--open-gh-issue
`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just give a space / empty line at the end to fix the symbol

And is missing run make install and make generate to have all samples/docs re-generated within

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And is missing run make install and make generate to have all samples/docs re-generated within

Doesn't alpha update already do that?

INFO Preparing Merge branch and performing merge branch_name=tmp-merge-15-08-25-11-41
...
INFO Running make manifests command=make manifests
...
...
INFO Running make generate command=make generate
...
...
INFO Running make fmt command=make fmt
...
...
INFO Running make vet command=make vet
...
...
INFO Running make lint-fix command=make lint-fix

kubebuilder alpha update \
--force \
--squash \
--preserve-path .github/workflows \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is created now manually; we need the URL for it.
Due this, could we remove from the default the --preserve-path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub Token does not have permission to alter the workflows directory by any means and it will fail to push the branch if we remove --preserve-path .github/workflows.

It's not only necessary for the PR. That's why I suggested we implement it internally, since it's mandatory for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we create the URL for the PR without gh
AND then we create the PR is valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We first need to push the branch. If we are not able to push, we can't construct the URL.

With GITHUB_TOKEN, we can't push the branch if it has changes in the .github/workflows directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we can't add workflows: write permisson to the workflow because that's not valid syntax. I've tried that.

We can only give permission to change workflows when we are creating a PAT or GitHub App.

See the available permissions for GITHUB_TOKEN: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants