1- name : Create Sub-Beta Branch
1+ name : create-sub-beta-branch
22
33on :
44 workflow_dispatch :
1919 description : " Product identifier for labeling (e.g., pilotone)"
2020 required : true
2121 type : string
22+ target_repository :
23+ description : " Target repository for auto-sync (e.g., tier4/pilot-auto.x2)"
24+ required : false
25+ type : string
26+ target_branch :
27+ description : " Target branch in the target repository (e.g., beta/v4.2/pilotone)"
28+ required : false
29+ type : string
2230
2331jobs :
2432 create-sub-beta-branch :
@@ -124,13 +132,50 @@ jobs:
124132 .github/workflows/auto-add-label.yaml
125133 echo "Copied auto-add-label.yaml to child branch"
126134
135+ - name : Render auto-sync-pilot-auto workflow for child branch
136+ run : |
137+ mkdir -p .github/workflows
138+ TEMPLATE_FILE="/tmp/workflow-templates/auto-sync-pilot-auto.yaml.template"
139+ OUTPUT_FILE=".github/workflows/auto-sync-pilot-auto.yaml"
140+
141+ if [ -f "$TEMPLATE_FILE" ]; then
142+ echo "Rendering auto-sync-pilot-auto.yaml template for child branch"
143+
144+ # Read template file
145+ TEMPLATE_CONTENT=$(cat "$TEMPLATE_FILE")
146+
147+ # Replace template variables
148+ # Using sed with different delimiters to avoid issues with slashes in branch names
149+ RENDERED_CONTENT=$(echo "$TEMPLATE_CONTENT" | \
150+ sed "s|{{SOURCE_BRANCH}}|${{ inputs.branch_name }}|g" | \
151+ sed "s|{{TARGET_REPOSITORY}}|${{ inputs.target_repository }}|g" | \
152+ sed "s|{{TARGET_BRANCH}}|${{ inputs.target_branch }}|g")
153+
154+ # Write rendered content to output file
155+ echo "$RENDERED_CONTENT" > "$OUTPUT_FILE"
156+
157+ echo "Created auto-sync-pilot-auto.yaml for child branch"
158+ echo "Source branch: ${{ inputs.branch_name }}"
159+ echo "Target repository: ${{ inputs.target_repository }}"
160+ echo "Target branch: ${{ inputs.target_branch }}"
161+ else
162+ echo "Warning: auto-sync-pilot-auto.yaml.template not found, skipping"
163+ fi
164+
127165 - name : Commit and push child branch
128166 run : |
129167 git add .github/branch-meta.yaml .github/workflows/auto-add-label.yaml
130- git commit -m "chore: initialize child branch with meta file and auto-label workflow
168+
169+ # Add the auto-sync workflow if it exists
170+ if [ -f ".github/workflows/auto-sync-pilot-auto.yaml" ]; then
171+ git add .github/workflows/auto-sync-pilot-auto.yaml
172+ fi
173+
174+ git commit -m "chore: initialize child branch with meta file and workflows
131175
132176 - Add .github/branch-meta.yaml with branch metadata
133177 - Add .github/workflows/auto-add-label.yaml for automatic PR labeling
178+ - Add .github/workflows/auto-sync-pilot-auto.yaml for syncing to ${{ inputs.target_repository }}
134179 - Base branch: ${{ inputs.base_branch }}
135180 - Product: ${{ inputs.product_name }}"
136181 git push origin "${{ inputs.branch_name }}"
@@ -252,3 +297,4 @@ jobs:
252297 echo "1. Review and merge the PR to ${{ inputs.base_branch }}"
253298 echo "2. The child branch ${{ inputs.branch_name }} is ready for use"
254299 echo "3. PRs merged to ${{ inputs.base_branch }} will be auto-cherry-picked to ${{ inputs.branch_name }}"
300+ echo "4. Changes to ${{ inputs.branch_name }} will be auto-synced to ${{ inputs.target_repository }} branch ${{ inputs.target_branch }}"
0 commit comments