-
Notifications
You must be signed in to change notification settings - Fork 179
fix release calendar logic gh token #1340
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
WalkthroughThis PR refactors Changes
Sequence Diagram(s)sequenceDiagram
participant Trigger as GitHub Event
participant Dispatch as Dispatch Logic
participant Guard as Schedule Guard<br/>(Fri/Sun)
participant Staging as Staging Job
participant Production as Production Job
Trigger->>Dispatch: workflow_dispatch OR schedule
Dispatch->>Dispatch: Check inputs.job_to_run
alt Manual Dispatch
Dispatch->>Staging: Route to staging/production<br/>based on input
Dispatch->>Production:
else Scheduled Event
Dispatch->>Guard: Evaluate day-of-week
Guard->>Staging: Proceed if Fri/Sun
Guard->>Staging: Skip & exit if not
Guard->>Production: Proceed if Fri/Sun
Guard->>Production: Skip & exit if not
end
Note over Staging: Check branch/PR exists<br/>Reuse or create branch<br/>Push with validation<br/>Generate PR body (Python)<br/>Create PR & apply labels
Note over Production: Verify staging not ahead<br/>Check existing PR<br/>Generate PR body (Python)<br/>Create PR & apply labels
sequenceDiagram
participant Job as Release Job
participant Git as Git/Local
participant Remote as Remote Repo
participant GH as GitHub API<br/>(secrets.GITHUB_TOKEN)
Job->>Git: Check local branch exists
alt Branch exists locally
Job->>Git: Reuse branch
else Branch missing
Job->>Git: Create new branch
end
Job->>Remote: Check remote branch present
alt Remote branch exists
Job->>Job: Skip push (already present)
else Remote missing
Job->>Git: Push branch to remote
Git->>Remote: Upload branch
end
Job->>Job: Generate pr_body.md<br/>(inline Python)
Job->>GH: Query existing PRs
alt PR already exists
Job->>Job: Log PR exists, exit
else No PR found
Job->>GH: Create new PR
GH->>GH: Apply labels<br/>(force-create)
Job->>Job: Log success
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas requiring extra attention:
Possibly Related PRs
Suggested Labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1).github/workflows/**/*.{yml,yaml}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-09-22T11:10:57.879ZApplied to files:
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| echo "Creating release branch ${BRANCH_NAME} from dev" | ||
| git fetch origin dev | ||
| git checkout -b "${BRANCH_NAME}" origin/dev | ||
| git push origin "${BRANCH_NAME}" | ||
| # Check if branch already exists locally | ||
| if git show-ref --verify --quiet refs/heads/"${BRANCH_NAME}"; then | ||
| echo "Branch ${BRANCH_NAME} already exists locally, checking out..." | ||
| git checkout "${BRANCH_NAME}" | ||
| else | ||
| git checkout -b "${BRANCH_NAME}" origin/dev | ||
| fi | ||
| # Check if branch already exists on remote | ||
| if git ls-remote --heads origin "${BRANCH_NAME}" | grep -q "${BRANCH_NAME}"; then | ||
| echo "Branch ${BRANCH_NAME} already exists on remote. Skipping push." | ||
| else | ||
| echo "Pushing branch ${BRANCH_NAME} to remote..." | ||
| if ! git push origin "${BRANCH_NAME}"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detect and update existing release branch before creating PR
When a release/staging-* branch already exists on the remote but no PR is open (for example, a previous run created the branch and the PR was closed), the new logic skips git push and proceeds to gh pr create. Because gh pr create --head ${BRANCH_NAME} uses whatever commit is already on GitHub, the workflow will create a fresh PR that references the stale branch contents instead of the current origin/dev snapshot. The previous implementation failed the job in this situation, making the staleness obvious. The job should either update the remote branch (fast-forward or force) or abort with an explicit error when the branch already exists, rather than silently reusing outdated code.
Useful? React with 👍 / 👎.
Summary by CodeRabbit
New Features
Improvements