Skip to content

Commit d241a83

Browse files
stuggiclaude
andcommitted
Use PR for openstack-k8s-operators-ci workflow updates
Change the 'Update openstack-k8s-operators-ci workflows' step to create a pull request instead of directly committing to main branch. This follows the same pattern as the openstack-operator update step. Changes: - Create a feature branch for the force-bump-branches.yaml update - Check if changes were made before creating PR - Create PR with descriptive title and body - Respect DRY_RUN mode - Use retry logic for git push operations - Remove direct commit to main branch Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent bae9d33 commit d241a83

1 file changed

Lines changed: 71 additions & 5 deletions

File tree

.github/workflows/create-release-branch-v1.yml

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,19 +705,85 @@ jobs:
705705
echo "::error::Failed to checkout main branch in openstack-k8s-operators-ci"
706706
exit 1
707707
fi
708-
708+
709709
if ! git pull origin main; then
710710
echo "::error::Failed to pull latest changes from main branch in openstack-k8s-operators-ci"
711711
exit 1
712712
fi
713713
714-
update_yaml_value ".github/workflows/force-bump-branches.yaml" ".jobs.trigger-jobs.strategy.matrix.branch" "${FORCE_BUMP_BRANCHES}"
714+
# Create a new branch for the PR
715+
PR_BRANCH="update-force-bump-branches-${BRANCH_NAME}-$(date +%s)"
716+
echo "Creating branch ${PR_BRANCH} for pull request..."
717+
if ! git checkout -b "${PR_BRANCH}"; then
718+
echo "::error::Failed to create branch ${PR_BRANCH}"
719+
exit 1
720+
fi
721+
722+
# Track if any changes were made
723+
CHANGES_MADE=false
724+
FILES_TO_COMMIT=""
715725
716-
# Commit and push changes if any were made
717-
commit_and_push "ci: Update force-bump-branches for ${BRANCH_NAME}" ".github/workflows/force-bump-branches.yaml" "${SOURCE_BRANCH}"
726+
# Update force-bump-branches.yaml
727+
WORKFLOW_FILE=".github/workflows/force-bump-branches.yaml"
728+
if [ -f "${WORKFLOW_FILE}" ]; then
729+
update_yaml_value "${WORKFLOW_FILE}" ".jobs.trigger-jobs.strategy.matrix.branch" "${FORCE_BUMP_BRANCHES}"
730+
if ! git diff --quiet -- "${WORKFLOW_FILE}"; then
731+
echo "Updated ${WORKFLOW_FILE}"
732+
FILES_TO_COMMIT="${WORKFLOW_FILE}"
733+
CHANGES_MADE=true
734+
fi
735+
else
736+
echo "No ${WORKFLOW_FILE} found."
737+
fi
738+
739+
# If changes were made, commit and create PR
740+
if [ "$CHANGES_MADE" = "true" ]; then
741+
echo "Changes detected. Preparing to commit and create pull request..."
742+
743+
# Show the changes
744+
echo "Showing all changes:"
745+
git diff
746+
747+
if [ "$DRY_RUN" = "true" ]; then
748+
echo "DRY RUN: Would have committed and created PR for openstack-k8s-operators-ci with changes to: ${FILES_TO_COMMIT}"
749+
else
750+
# Configure git
751+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
752+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
753+
754+
# Commit all changes
755+
git add ${FILES_TO_COMMIT}
756+
git commit -m "ci: Update force-bump-branches for ${BRANCH_NAME}"
757+
758+
# Push the branch
759+
echo "Pushing branch ${PR_BRANCH}..."
760+
if ! retry_command 3 5 "Pushing branch ${PR_BRANCH}" git push origin "${PR_BRANCH}"; then
761+
echo "::error::Failed to push branch ${PR_BRANCH}"
762+
exit 1
763+
fi
764+
765+
# Create pull request using GitHub CLI
766+
echo "Creating pull request..."
767+
PR_BODY="This PR updates the force-bump-branches workflow to include the ${BRANCH_NAME} branch."$'\n\n'"Changes included:"$'\n'"- Update force-bump-branches.yaml matrix to: ${FORCE_BUMP_BRANCHES}"$'\n\n'"Generated automatically by the create-release-branch workflow."
768+
PR_URL=$(gh pr create \
769+
--title "ci: Update force-bump-branches for ${BRANCH_NAME}" \
770+
--body "${PR_BODY}" \
771+
--base main \
772+
--head "${PR_BRANCH}" \
773+
--repo "${ORG_NAME}/openstack-k8s-operators-ci")
774+
775+
if [ $? -ne 0 ]; then
776+
echo "::error::Failed to create pull request"
777+
exit 1
778+
fi
779+
780+
echo "✅ Pull request created successfully: ${PR_URL}"
781+
fi
782+
else
783+
echo "No changes detected in openstack-k8s-operators-ci. Skipping pull request creation."
784+
fi
718785
719786
cd .. && rm -rf "$TEMP_DIR"
720-
echo "Workflow finished."
721787
722788
retag-and-push-rabbitmq-cluster-operator-index:
723789
# Only run if not a dry run, parameter is enabled, and create-branches job succeeded

0 commit comments

Comments
 (0)