$npx -y skills add AgentWorkforce/relay --skill deploying-to-staging-environmentUse when deploying changes to staging across relay, relay-dashboard, and relay-cloud repos - coordinates multi-repo branch syncing using git worktrees, automatically triggers staging deployments via GitHub Actions
| 1 | # Deploying to Staging Environment |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | The staging environment deployment is a coordinated multi-repo process that synchronizes code across three repositories (relay, relay-dashboard, relay-cloud) and automatically triggers deployment via GitHub Actions. Staging deployments ensure feature verification before production while keeping main branch clean during development. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - **Integrating features across repos** - Multiple components depend on changes in different repos |
| 10 | - **Testing feature branches together** - Verify feature branch changes don't break integration |
| 11 | - **Promoting main to staging** - Standard sync to keep staging up-to-date with latest main |
| 12 | - **Verifying deployment readiness** - Test infrastructure changes or deployment workflows |
| 13 | - **Cross-team coordination** - Share feature branches for integration testing |
| 14 | |
| 15 | **When NOT to use:** |
| 16 | |
| 17 | - Emergency hotfixes (use production deployment instead) |
| 18 | - Single-repo changes only (push directly if not blocking other repos) |
| 19 | - Testing without intent to deploy (use local environment instead) |
| 20 | |
| 21 | ## Architecture |
| 22 | |
| 23 | The staging deployment system consists of: |
| 24 | |
| 25 | ``` |
| 26 | Three Repos (relay, relay-dashboard, relay-cloud) |
| 27 | ↓ |
| 28 | Staging Branches (synced via git push) |
| 29 | ↓ |
| 30 | relay-cloud staging push triggers GitHub Actions |
| 31 | ↓ |
| 32 | Deploy-Staging Workflow (deploy-staging.yml) |
| 33 | ↓ |
| 34 | Fly.io Staging Environment (agent-relay-staging) |
| 35 | ↓ |
| 36 | Automatic health check verification |
| 37 | ``` |
| 38 | |
| 39 | **Key details:** |
| 40 | |
| 41 | - Each repo has independent staging branch |
| 42 | - relay-cloud staging branch push triggers automatic deployment |
| 43 | - Workflow accepts optional relay/dashboard branch overrides |
| 44 | - Falls back to main if specified branch doesn't exist |
| 45 | - Workspace image builds in parallel with API deployment |
| 46 | |
| 47 | ## Quick Reference |
| 48 | |
| 49 | ### Standard Workflow (All Repos) |
| 50 | |
| 51 | ```bash |
| 52 | # 1. Create git worktree for staging work (BEST PRACTICE) |
| 53 | cd /data/repos/relay |
| 54 | git worktree add .worktrees/staging-push main |
| 55 | cd .worktrees/staging-push |
| 56 | |
| 57 | # 2. Push latest main to staging (fetch fresh) |
| 58 | git fetch origin main:main |
| 59 | git push origin main:staging |
| 60 | |
| 61 | # 3. Or push current feature branch to staging (if desired) |
| 62 | git fetch origin feature/your-branch:feature/your-branch |
| 63 | git push origin feature/your-branch:staging |
| 64 | |
| 65 | # 4. Clean up worktree |
| 66 | cd /data/repos/relay |
| 67 | git worktree remove .worktrees/staging-push |
| 68 | ``` |
| 69 | |
| 70 | ### Relay-Dashboard |
| 71 | |
| 72 | ```bash |
| 73 | cd /data/repos/relay-dashboard |
| 74 | git worktree add .worktrees/staging-push main |
| 75 | cd .worktrees/staging-push |
| 76 | git fetch origin main:main |
| 77 | git push origin main:staging |
| 78 | cd /data/repos/relay-dashboard |
| 79 | git worktree remove .worktrees/staging-push |
| 80 | ``` |
| 81 | |
| 82 | ### Relay-Cloud (Triggers Deployment) |
| 83 | |
| 84 | ```bash |
| 85 | cd /data/repos/relay-cloud |
| 86 | git worktree add .worktrees/staging-push main |
| 87 | cd .worktrees/staging-push |
| 88 | git fetch origin main:main |
| 89 | git push origin main:staging |
| 90 | # ⚠️ This push triggers deploy-staging.yml workflow |
| 91 | cd /data/repos/relay-cloud |
| 92 | git worktree remove .worktrees/staging-push |
| 93 | ``` |
| 94 | |
| 95 | ## Implementation |
| 96 | |
| 97 | ### Why Git Worktrees? |
| 98 | |
| 99 | Git worktrees provide several benefits for staging workflows: |
| 100 | |
| 101 | 1. **Isolation** - Work on staging without changing main working directory state |
| 102 | 2. **Safety** - Feature branch checked out in worktree won't affect your current work |
| 103 | 3. **Cleanliness** - No lingering state changes after pushing |
| 104 | 4. **Best practice** - Standard DevOps approach for multi-branch operations |
| 105 | |
| 106 | ### Step-by-Step Deployment Process |
| 107 | |
| 108 | #### Prerequisites |
| 109 | |
| 110 | - Access to all three repos with push permission |
| 111 | - Current working directory: one of the repos |
| 112 | - No uncommitted changes blocking worktree creation |
| 113 | |
| 114 | #### Execute Staging Push Across All Repos |
| 115 | |
| 116 | **Step 1: Relay** |
| 117 | |
| 118 | ```bash |
| 119 | cd /data/repos/relay |
| 120 | git worktree add .worktrees/staging-push main |
| 121 | cd .worktrees/staging-push |
| 122 | git fetch origin main:main |
| 123 | git push origin main:staging |
| 124 | cd /data/repos/relay |
| 125 | git worktree remove .worktrees/staging-push |
| 126 | ``` |
| 127 | |
| 128 | Expected output: |
| 129 | |
| 130 | ``` |
| 131 | Updated 'main' to 'origin/main' |
| 132 | remote: Create pull request for staging... |
| 133 | To github.com:AgentWorkforce/relay.git |
| 134 | [new branch] main -> staging |
| 135 | or |
| 136 | * [up-to-date] main -> staging |
| 137 | ``` |
| 138 | |
| 139 | **Step 2: Relay-Dashboard** |
| 140 | |
| 141 | ```bash |
| 142 | cd /data/repos/relay-dashboard |
| 143 | git worktree add .worktrees/staging-push main |
| 144 | cd .worktrees/staging-push |
| 145 | git fetch origin main:main |
| 146 | git push origin main:staging |
| 147 | cd /data/repos/relay-dashboard |
| 148 | git worktree remove .worktrees/staging-push |
| 149 | ``` |
| 150 | |
| 151 | **Step 3: Relay-Cloud (Triggers Deployment)** |
| 152 | |
| 153 | ```bash |
| 154 | cd /data/repos/relay-cloud |
| 155 | git worktree add .worktrees/staging-push main |
| 156 | cd .worktrees/staging-push |
| 157 | git fetch origin main:main |
| 158 | git push origin main:staging |
| 159 | # Deployment starts automatically! |
| 160 | cd /data/repos/relay-cloud |
| 161 | git worktree remove .worktrees/staging-push |
| 162 | ``` |
| 163 | |
| 164 | #### Verify Deployment |
| 165 | |
| 166 | After pushing relay-cloud, GitHub Actions starts automatically |