Skip to content

feat: add production deploy and automatic staging sync - #75

Merged
GRACENOBLE merged 2 commits into
mainfrom
add-deploy-and-staging-sync
Jul 17, 2026
Merged

feat: add production deploy and automatic staging sync#75
GRACENOBLE merged 2 commits into
mainfrom
add-deploy-and-staging-sync

Conversation

@GRACENOBLE

@GRACENOBLE GRACENOBLE commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • make deploy-prod rebases production onto main and force-pushes (with lease) after a confirmation prompt — the manual trigger for a production deploy.
  • .github/workflows/sync-staging.yml keeps staging in sync with main automatically on every merge, via scripts/sync-staging.sh (same rebase + force-with-lease model, but unattended).
  • Documented both flows in RUNBOOK.md ("Triggering a deploy" section, split into Staging (automatic) / Production (manual)) and README.md.

Test plan

  • Confirm Settings → Actions → General → Workflow permissions is set to "Read and write permissions" so the sync-staging workflow can push.
  • If staging is a protected branch, add a bypass rule for the workflow's push identity.
  • Merge this PR and verify the Sync Staging workflow runs and fast-forwards staging to match main.
  • Run make deploy-prod against a test repo state to confirm the confirmation prompt and push behave as documented.

Summary by CodeRabbit

  • New Features

    • Added automatic synchronization of the staging branch when changes reach the main branch.
    • Added a production deployment command for Windows and non-Windows environments.
    • Production deployments now rebase changes onto main and use a guarded update process with confirmation prompts.
  • Documentation

    • Expanded the README and runbook with deployment commands, branch workflows, conflict handling, and migration guidance.

- make deploy-prod rebases `production` onto `main` and force-pushes
  (with lease) after a confirmation prompt, for manually triggering a
  production deploy.
- .github/workflows/sync-staging.yml keeps `staging` in sync with
  `main` automatically on every merge via scripts/sync-staging.sh.
- Document both flows in RUNBOOK.md and README.md.
@github-actions github-actions Bot added the area: infra CI/CD, infrastructure, deployment, and DevOps label Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@GRACENOBLE, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad625906-e12e-4493-b701-e71164179d12

📥 Commits

Reviewing files that changed from the base of the PR and between e9a98ea and cccf3fc.

📒 Files selected for processing (5)
  • .github/workflows/sync-staging.yml
  • RUNBOOK.md
  • scripts/deploy-prod.ps1
  • scripts/deploy-prod.sh
  • scripts/sync-staging.sh
📝 Walkthrough

Walkthrough

Adds GitHub Actions automation to synchronize staging from main, platform-specific tooling to advance production, a Makefile entry point, and README/RUNBOOK documentation for the deployment workflows.

Changes

Deployment automation

Layer / File(s) Summary
Staging synchronization workflow
.github/workflows/sync-staging.yml, scripts/sync-staging.sh
Runs staging synchronization on pushes to main or manual dispatch, rebases staging onto main, handles conflicts, and uses --force-with-lease.
Production deployment flow
Makefile, scripts/deploy-prod.sh, scripts/deploy-prod.ps1
Adds make deploy-prod with platform-specific scripts that reset and rebase production, prompt for confirmation, handle conflicts, and force-push safely.
Deployment documentation
README.md, RUNBOOK.md
Documents the new scripts, commands, branch strategy, confirmation behavior, conflict handling, and deployment limitations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Main
  participant SyncWorkflow
  participant SyncScript
  participant Staging
  Main->>SyncWorkflow: push or manual dispatch
  SyncWorkflow->>SyncScript: execute sync-staging.sh
  SyncScript->>Staging: rebase onto main
  SyncScript->>Staging: force-with-lease push
Loading
sequenceDiagram
  participant Developer
  participant Make
  participant DeployScript
  participant Production
  Developer->>Make: run deploy-prod
  Make->>DeployScript: invoke shell or PowerShell script
  DeployScript->>Production: rebase onto main
  DeployScript->>Developer: request confirmation
  DeployScript->>Production: force-with-lease push
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: production deployment and automatic staging synchronization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-deploy-and-staging-sync

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/sync-staging.yml:
- Around line 27-28: Update the git identity configuration in the workflow to
use the standard GitHub Actions bot name and email instead of the hardcoded
personal identity, preserving the existing configuration steps.

In `@scripts/deploy-prod.sh`:
- Around line 64-70: Update the read command in the confirmation block of the
deployment script to tolerate EOF by appending the requested non-failing
fallback, allowing execution to continue to the existing case statement and
print its clean abort message in non-interactive environments.

In `@scripts/sync-staging.sh`:
- Around line 16-26: Update the deployment-branch initialization logic in
scripts/sync-staging.sh lines 16-26, scripts/deploy-prod.sh lines 32-42, and
scripts/deploy-prod.ps1 lines 25-40 to fetch the entire remote rather than named
branches, detect whether the remote sync branch exists, and create or reset the
local branch from that remote branch when present; otherwise, fall back to
branching from main. Use shell syntax in the two .sh scripts and PowerShell
syntax in deploy-prod.ps1, preserving strict-error behavior and avoiding
captured standard output during the PowerShell existence check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42284443-9c1a-4e9e-9576-faaa0d26b040

📥 Commits

Reviewing files that changed from the base of the PR and between bdebf09 and e9a98ea.

📒 Files selected for processing (7)
  • .github/workflows/sync-staging.yml
  • Makefile
  • README.md
  • RUNBOOK.md
  • scripts/deploy-prod.ps1
  • scripts/deploy-prod.sh
  • scripts/sync-staging.sh

Comment thread .github/workflows/sync-staging.yml Outdated
Comment thread scripts/deploy-prod.sh
Comment thread scripts/sync-staging.sh Outdated
…g sync

- Resolve sync-staging.yml's git identity from github.actor instead of a
  hardcoded personal name/email, so forks of this template don't silently
  force-push commits attributed to someone else.
- Switch to a PAT (SYNC_STAGING_PAT) for the staging sync push, since pushes
  made with the default GITHUB_TOKEN don't trigger other on:push workflows
  and would leave CD silently un-triggered.
- Harden deploy-prod.sh/.ps1 and sync-staging.sh: fetch the whole remote and
  fall back to branching from main instead of crashing when the
  staging/production branch doesn't exist yet (first run of the template).
- Make deploy-prod.sh's confirmation prompt tolerate EOF in non-interactive
  environments instead of crashing past the abort message.
- Update RUNBOOK.md with the PAT setup steps and rationale.
@GRACENOBLE
GRACENOBLE merged commit fd765c9 into main Jul 17, 2026
2 checks passed
@GRACENOBLE
GRACENOBLE deleted the add-deploy-and-staging-sync branch July 17, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: infra CI/CD, infrastructure, deployment, and DevOps

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant