Update the subtree.yml workflow file to create a PR and merge#248
Update the subtree.yml workflow file to create a PR and merge#248richm merged 1 commit intolinux-system-roles:mainfrom
Conversation
Reviewer's GuideThis PR converts the subtree sync workflow to a pull-request-based flow by creating a timestamped branch, detecting changes, creating and auto-merging a PR with the GitHub CLI, replacing the direct push to main. Sequence diagram for the new subtree sync workflow via PRsequenceDiagram
participant Workflow as GitHub Actions Workflow
participant Git as git
participant GHCLI as GitHub CLI (gh)
participant GitHub as GitHub
Workflow->>Git: Checkout main
Workflow->>Git: Create new branch (sync-ansible-pcp-subtree-<timestamp>)
Workflow->>Git: Pull subtree from upstream
Workflow->>Git: Check for changes
alt Changes detected
Workflow->>Git: Push branch to origin
Workflow->>GHCLI: Create PR to main
GHCLI->>GitHub: Create PR
Workflow->>GHCLI: Merge PR (squash, delete branch)
GHCLI->>GitHub: Merge PR and delete branch
else No changes
Workflow->>Git: Delete branch
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @sfeifer - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `.github/workflows/subtree.yml:26` </location>
<code_context>
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
+
+ BRANCH_NAME="sync-ansible-pcp-subtree-$(date +%Y%m%d-%H%M%S)"
+ git checkout -b "$BRANCH_NAME"
+
</code_context>
<issue_to_address>
Branch naming may lead to collisions if jobs run within the same second.
Appending a random suffix or the GitHub run ID to the branch name will help prevent collisions from simultaneous runs.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
BRANCH_NAME="sync-ansible-pcp-subtree-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH_NAME"
=======
BRANCH_NAME="sync-ansible-pcp-subtree-$(date +%Y%m%d-%H%M%S)-${GITHUB_RUN_ID:-$RANDOM}"
git checkout -b "$BRANCH_NAME"
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `.github/workflows/subtree.yml:51` </location>
<code_context>
+ echo "Created PR: $PR_URL"
+
+ # Wait for PR to be fully created
+ sleep 10
+
+ gh pr merge "$PR_URL" --squash --delete-branch
</code_context>
<issue_to_address>
Using a fixed sleep for PR creation is brittle.
Consider replacing the fixed sleep with polling or another method to reliably detect when the PR is ready before merging.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| BRANCH_NAME="sync-ansible-pcp-subtree-$(date +%Y%m%d-%H%M%S)" | ||
| git checkout -b "$BRANCH_NAME" | ||
|
|
There was a problem hiding this comment.
suggestion (bug_risk): Branch naming may lead to collisions if jobs run within the same second.
Appending a random suffix or the GitHub run ID to the branch name will help prevent collisions from simultaneous runs.
| BRANCH_NAME="sync-ansible-pcp-subtree-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -b "$BRANCH_NAME" | |
| BRANCH_NAME="sync-ansible-pcp-subtree-$(date +%Y%m%d-%H%M%S)-${GITHUB_RUN_ID:-$RANDOM}" | |
| git checkout -b "$BRANCH_NAME" | |
| echo "Created PR: $PR_URL" | ||
|
|
||
| # Wait for PR to be fully created | ||
| sleep 10 |
There was a problem hiding this comment.
suggestion: Using a fixed sleep for PR creation is brittle.
Consider replacing the fixed sleep with polling or another method to reliably detect when the PR is ready before merging.
The "Sync ansible-pcp git subtree" github action no longer works as intended due to permission changes preventing directly pushing to main. This PR introduces changes to the subtree.yml workflow file to create and merge a PR, which is the accepted way of introducing changes.
Summary by Sourcery
Switch the ansible-pcp subtree sync workflow from direct pushes to a PR-based process using the GitHub CLI to comply with updated permissions.
Enhancements:
CI: