Skip to content

feat: demonstration of the sub-beta-branch creation#2623

Open
Owen-Liuyuxuan wants to merge 12 commits intomainfrom
feat/sub-beta-branch
Open

feat: demonstration of the sub-beta-branch creation#2623
Owen-Liuyuxuan wants to merge 12 commits intomainfrom
feat/sub-beta-branch

Conversation

@Owen-Liuyuxuan
Copy link

At the current design we do not support creating sub universe

Example standard for creating sub-beta-branch

Design principle:

Use a workflow to create universe sub-beta-branch.

  • Need to specify base beta branch, commit, and product name as input
    The workflow will:
  • Create or update the automatic cherry-pick features, initialize the PR to the base beta branch.
    • The base branch will need to maintain a list of sub-branches in .github/children-branches.yaml
    • The existing automatic cherry-pick will be adopted to read this children-branches.
    • Automatically link cherry-picks, whenever PR merged into base beta branch, there will be an automatically cherry-pick to all of the child branches.
  • Create a PR to Whenever there is a manual PR into the child-universe (not robotic cherry-picks), it will automatically tag the PR with two labels, {base_branch} and {product_name}
flowchart TB
    subgraph setup [Initial Setup - One Time]
        A[Integrator decides to create product branch] --> B[Go to Actions tab]
        B --> C[Select 'Create Sub-Beta Branch']
        C --> D[Fill in inputs]
        D --> D1[base_branch: beta/v4.2]
        D --> D2[branch_name: beta/v4.2-myproduct]
        D --> D3[product_name: myproduct]
        D --> D4[commit: optional]
        D1 & D2 & D3 & D4 --> E[Run workflow]
        E --> F[Review & merge the registration PR]
        F --> G[Child branch is ready!]
    end
    subgraph daily [Daily Operations]
        H[Developer creates PR to base branch] --> I{PR merged to base?}
        I -->|Yes| J[Auto cherry-pick to all children]
        J --> K[Review cherry-pick PRs]
        L[Developer creates PR to child branch] --> M{Is author a bot?}
        M -->|No| N[Auto-labeled with base_branch + product_name]
        M -->|Yes| O[No labels added - automated PR]
    end
    subgraph management [Branch Management]
        P[Add more child branches] --> Q[Run workflow again with same base]
        Q --> R[New child registered in children-branches.yaml]
        S[View all children] --> T[Check .github/children-branches.yaml in base branch]
    end
    G --> daily
    G --> management
Loading

Working Example

Trigger action to create sub-branch

2026-01-07_18-37

Register child branch to beta branch

2026-01-07_18-36

Beta branch development will be automatically cherry-pick to children

2026-01-07_18-46

Children will be marked how they created

image

Direct PR to children branches will be automatically tagged

2026-01-07_18-40

Examine singular project PRs with tags

2026-01-07_18-43

Support Multiple Children

2026-01-07_18-47 2026-01-07_18-48

Mechanism

flowchart TD
    subgraph creation [create-sub-beta-branch.yaml - Branch Creation]
        direction TB
        C1[Workflow triggered] --> C2[Cache templates from main branch]
        C2 --> C3[Checkout base_branch]
        C3 --> C4[Create child branch from commit]
        C4 --> C5[Add branch-meta.yaml to child]
        C5 --> C6[Add auto-add-label.yaml to child]
        C6 --> C7[Push child branch]
        C7 --> C8{auto-update-child.yaml exists?}
        C8 -->|No| C9[Create auto-update-child.yaml]
        C8 -->|Yes| C10[Skip]
        C9 --> C11[Update children-branches.yaml]
        C10 --> C11
        C11 --> C12[Create PR to base branch]
    end
    subgraph baseBranch [Base Branch - auto-update-child.yaml]
        direction TB
        B1[PR opened/reopened to base] --> B2{Author contains 'bot'?}
        B2 -->|No| B3[Add tag:enable-automatic-cherry-pick label]
        B2 -->|Yes| B4[Skip labeling]
        B5[PR closed/labeled] --> B6{PR merged + has label + no cherry emoji?}
        B6 -->|Yes| B7[Read children-branches.yaml]
        B7 --> B8[For each child branch]
        B8 --> B9[Cherry-pick commit]
        B9 --> B10[Create PR to child with cherry emoji]
        B10 --> B11[Comment on original PR]
        B6 -->|No| B12[Skip cherry-pick]
    end
    subgraph childBranch [Child Branch - auto-add-label.yaml]
        direction TB
        CH1[PR opened/reopened to child] --> CH2{Author contains 'bot'?}
        CH2 -->|No| CH3[Read branch-meta.yaml]
        CH3 --> CH4[Wait 10 seconds]
        CH4 --> CH5[Create labels if not exist]
        CH5 --> CH6[Add base_branch + product_name labels]
        CH2 -->|Yes| CH7[Skip - automated cherry-pick PR]
    end
    subgraph files [Configuration Files]
        direction LR
        F1[".github/branch-meta.yaml<br/>(in child branch)"]
        F2[".github/children-branches.yaml<br/>(in base branch)"]
        F3[".github/workflow-templates/<br/>*.template (in main)"]
    end
    creation --> baseBranch
    creation --> childBranch
    baseBranch -->|Cherry-pick PRs| childBranch
Loading

Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq

- name: Update children-branches.yaml
Copy link

Choose a reason for hiding this comment

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

nit: I would like "child branches" instead of "children branches" (here's the answer from Gemini)


In most contexts, "child branches" reads more naturally and is the standard convention in technical, botanical, and linguistic fields.

While "children" is the plural of "child," English grammar typically uses the singular form of a noun when it acts as an adjective (a "noun adjunct") to modify another noun.

Why "Child Branches" Wins

When you combine two nouns, the first noun describes the type or status of the second. Even if the second noun is plural, the first usually stays singular.

  • The Rule: We say "shoe stores" (not shoes stores) or "apple trees" (not apples trees).
  • The Application: * Child branch (singular)
    • Child branches (plural)

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a comprehensive workflow system for creating and managing sub-beta branches with automatic cherry-picking capabilities. The implementation allows integrators to create product-specific branches that automatically receive changes from their parent beta branch, with proper labeling and tracking mechanisms.

Changes:

  • Added workflow for creating sub-beta branches with metadata and automatic registration
  • Implemented automatic cherry-picking from base branches to child branches
  • Added automatic labeling for manual PRs to child branches

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 28 comments.

File Description
.github/create-sub-beta-branch.yaml Workflow dispatcher for creating and registering new sub-beta branches with validation and PR creation
.github/workflow-templates/auto-update-child.yaml.template Template for base branch workflow that auto-labels PRs and cherry-picks to children
.github/workflow-templates/auto-add-label.yaml.template Template for child branch workflow that auto-labels manual PRs with base branch and product info

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

private_key: ${{ secrets.PRIVATE_KEY }}

- name: Create label if it doesn't exist
uses: actions/github-script@v6
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The actions/github-script action is using version v6, but the existing codebase uses v7 (as seen in .github/workflows/co-pilot-auto-client.yaml). Consider updating to v7 for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +36
if [[ -z "${{ inputs.branch_name }}" ]]; then
echo "Error: branch_name is required"
exit 1
fi
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The validation only checks if branch_name is non-empty using -z, but doesn't validate the format or check for invalid characters. Branch names with special characters, spaces, or invalid Git branch name patterns could cause issues later. Consider adding validation to ensure the branch name follows Git naming conventions (e.g., no spaces, no special characters like .., ~, ^, :, ?, *, [, \).

Suggested change
if [[ -z "${{ inputs.branch_name }}" ]]; then
echo "Error: branch_name is required"
exit 1
fi
branch_name="${{ inputs.branch_name }}"
if [[ -z "$branch_name" ]]; then
echo "Error: branch_name is required"
exit 1
fi
# Validate branch_name against Git's refname rules
if ! git check-ref-format "refs/heads/$branch_name"; then
echo "Error: branch_name '$branch_name' is not a valid Git branch name"
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +141
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

This job again uses the third-party GitHub Action tibdex/github-app-token@v2 pinned only to a mutable tag while minting a GitHub App token used to create cherry-pick PRs. Compromise of the action repository or tag would let an attacker run arbitrary code in this step to steal the generated token and perform privileged operations on the repository. Pin this action to a specific commit SHA and treat it as sensitive supply-chain code.

Copilot uses AI. Check for mistakes.
Comment on lines +143 to +150
- name: Cherry pick
id: cherry-pick
uses: tier4/action-auto-cherry-pick@v1.0.5
with:
target-branch: ${{ matrix.child-branch }}
pr-title-suffix: 🍒${{ matrix.child-branch }}
pr-labels: bot,cherry-pick
pr-creator-token: ${{ steps.generate-token.outputs.token }}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The workflow invokes the third-party action tier4/action-auto-cherry-pick@v1.0.5 pinned only to a version tag and passes it a high-privilege GitHub App token via pr-creator-token. If the action's repository or the v1.0.5 tag is compromised, an attacker could modify the action code to exfiltrate this token or push arbitrary changes under the app's identity. Pin this action to an immutable commit SHA and review its usage as part of your supply-chain hardening.

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +41
- name: Generate token
if: steps.meta.outputs.skip != 'true'
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

This job uses the third-party GitHub Action tibdex/github-app-token@v2 pinned only to a mutable tag while passing it secrets.APP_ID and secrets.PRIVATE_KEY. If the action repository or tag is compromised, malicious code could exfiltrate these secrets or misuse the generated GitHub App token for privileged operations. Pin this action to a specific commit SHA and treat it as a high-value component in your supply-chain security posture.

Copilot uses AI. Check for mistakes.
Comment on lines +91 to +95
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq

Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

This step installs yq by downloading a precompiled binary from GitHub using the floating latest URL and executing it without any checksum or signature verification. If the upstream repository or release is compromised, an attacker could run arbitrary code in this CI job and exfiltrate GITHUB_TOKEN or modify build artifacts. Pin the download to a specific version and enforce integrity checking (or use a trusted package source) before executing the binary.

Copilot uses AI. Check for mistakes.
Comment on lines +164 to +167
- name: Install yq for YAML operations
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
Copy link

@paulsohn paulsohn Feb 5, 2026

Choose a reason for hiding this comment

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

somewhat nitty, but I would rather not use latest. Using a fixed version + checksum would be safer.

https://github.com/tier4/pilot-auto/blob/cb54d4bc9f87fe36caa92e22df30d6104ef64aae/.github/workflows/check_base_tag.yml#L31-L33

Alternatively, for github action, we can just have uses: mikefarah/yq@v4.52.2 (although this contains no checksum, but at least github will guarantee that the tag is not moved. We can also use commit hash if really doubtful)

https://github.com/marketplace/actions/yq-portable-yaml-processor

Copy link

@paulsohn paulsohn Feb 5, 2026

Choose a reason for hiding this comment

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

Ah, copilot already said that.

Copy link
Author

Choose a reason for hiding this comment

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

dac5d2b
Thank you, this is good suggestion.

@paulsohn
Copy link

paulsohn commented Feb 5, 2026

This seems good for a workaround. I'll look into this if this can be automated from release_infos. Adding workflow-call might be helpful.

Owen-Liuyuxuan and others added 3 commits February 12, 2026 15:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

SonarCloud found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

pre-commit-ci bot and others added 7 commits February 12, 2026 08:07
Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com>
@sonarqubecloud
Copy link

@Owen-Liuyuxuan
Copy link
Author

@paulsohn At this step, I added the workflow to update the pilot-auto hash for these automatically for the special branch.

@Owen-Liuyuxuan Owen-Liuyuxuan marked this pull request as ready for review February 12, 2026 08:25
required: false
type: string
branch_name:
description: Full name of the new sub-branch (e.g., beta/v4.2-pilotone)

Choose a reason for hiding this comment

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

I see pilotone is not a real project, but we want to prevent users from accidentally exposing their project name into this public repository. Can we add a warning statement for this?

Copy link
Author

Choose a reason for hiding this comment

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

Actually, this is an OSS repository, so unreal project is good.

Choose a reason for hiding this comment

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

Yes, I'm not commenting about 'pilotone'. I'm concerned about our developers can carelessly input our real project name instead of an anonymized one if we don't provide an appropriate description.

Copy link

@paulsohn paulsohn Feb 16, 2026

Choose a reason for hiding this comment

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

@Owen-Liuyuxuan It seems that SI internal discussion disagree for creating sub branches for projects, even if it's a codename. As such, I can't fully support this PR for now.

https://star4.slack.com/archives/C03QU7K50D8/p1770957058736699

Copy link
Author

Choose a reason for hiding this comment

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

@paulsohn
I also agree with this. But this test PR is the baseline for E2E branch developments.

Choose a reason for hiding this comment

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

I see. Then maybe we'd better confine this for E2E purpose only, and it should be explicitly stated that this is not for creating proprietary project branches.

Copy link
Author

Choose a reason for hiding this comment

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

@paulsohn This is also not for E2E only, as long as you believe the experiment/project is suitable to use a new branch, it is OK.

The question of whether the project should open a new private universe is out of the scope here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants