|
| 1 | +# GitHub Actions Secrets Setup |
| 2 | + |
| 3 | +For CI/CD automation to deploy to cloud platforms, add these secrets to your GitHub repository. |
| 4 | + |
| 5 | +## 📋 Where to Add Secrets |
| 6 | + |
| 7 | +1. Go to GitHub repository → Settings → Secrets and variables → Actions |
| 8 | +2. Click "New repository secret" |
| 9 | +3. Add each secret below |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## 🔑 Required Secrets by Platform |
| 14 | + |
| 15 | +### For Render.com |
| 16 | +``` |
| 17 | +RENDER_API_KEY = Your Render API key from https://dashboard.render.com/account/api-tokens |
| 18 | +RENDER_SERVICE_ID = Your service ID (shown in Render dashboard URL) |
| 19 | +RENDER_DEPLOY_HOOK = Webhook URL for automatic deployments |
| 20 | +``` |
| 21 | + |
| 22 | +**Get these:** |
| 23 | +1. Log in to Render Dashboard |
| 24 | +2. Account → API Tokens → Create new token |
| 25 | +3. Copy the token as `RENDER_API_KEY` |
| 26 | +4. In Services, click your service, copy the service ID from URL |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +### For Railway.app |
| 31 | +``` |
| 32 | +RAILWAY_TOKEN = Your Railway API token |
| 33 | +RAILWAY_SERVICE = Your service name (ai-downtime-api) |
| 34 | +``` |
| 35 | + |
| 36 | +**Get these:** |
| 37 | +1. Log in to Railway Dashboard |
| 38 | +2. Account → API Tokens → Generate new |
| 39 | +3. Copy token as `RAILWAY_TOKEN` |
| 40 | +4. Find service name in dashboard |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +### For Fly.io |
| 45 | +``` |
| 46 | +FLY_API_TOKEN = Your Fly.io API token |
| 47 | +FLY_APP_NAME = Your app name (ai-downtime-system) |
| 48 | +``` |
| 49 | + |
| 50 | +**Get these:** |
| 51 | +1. Log in to Fly Dashboard |
| 52 | +2. Account → Access Tokens → Create new |
| 53 | +3. Copy token as `FLY_API_TOKEN` |
| 54 | +4. App name from fly.toml or dashboard |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +### For Vercel (Dashboard) |
| 59 | +``` |
| 60 | +VERCEL_TOKEN = Your Vercel API token |
| 61 | +VERCEL_ORG_ID = Your organization ID |
| 62 | +VERCEL_PROJECT_ID = Project ID for dashboard |
| 63 | +``` |
| 64 | + |
| 65 | +**Get these:** |
| 66 | +1. Log in to Vercel Dashboard |
| 67 | +2. Account Settings → Tokens → Create new token |
| 68 | +3. Copy as `VERCEL_TOKEN` |
| 69 | +4. Get IDs from project settings |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +### For AWS (App Runner / EKS) |
| 74 | +``` |
| 75 | +AWS_ACCESS_KEY_ID = Your AWS access key |
| 76 | +AWS_SECRET_ACCESS_KEY = Your AWS secret key |
| 77 | +AWS_REGION = us-east-1 (or your region) |
| 78 | +ECR_REGISTRY = Your ECR registry URL |
| 79 | +ECR_REPOSITORY = ai-downtime-app |
| 80 | +``` |
| 81 | + |
| 82 | +**Get these:** |
| 83 | +1. AWS Console → IAM → Users → Create user |
| 84 | +2. Generate access keys |
| 85 | +3. Store safely in GitHub secrets |
| 86 | +4. ECR info: AWS Console → ECR → Repositories |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +### For Slack Notifications (Optional) |
| 91 | +``` |
| 92 | +SLACK_WEBHOOK_URL = Your Slack incoming webhook |
| 93 | +SLACK_CHANNEL = #deployments |
| 94 | +``` |
| 95 | + |
| 96 | +**Get this:** |
| 97 | +1. Slack App → Incoming Webhooks → Create new |
| 98 | +2. Copy webhook URL |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## 🚀 GitHub Actions Workflow Setup |
| 103 | + |
| 104 | +### 1. Create `.github/workflows/deploy-cloud.yml` |
| 105 | + |
| 106 | +Already provided! It includes jobs for all platforms: |
| 107 | + |
| 108 | +```yaml |
| 109 | +name: Deploy to Cloud Platforms |
| 110 | + |
| 111 | +on: |
| 112 | + push: |
| 113 | + branches: [ main ] |
| 114 | + workflow_dispatch: |
| 115 | + |
| 116 | +jobs: |
| 117 | + deploy-render: |
| 118 | + runs-on: ubuntu-latest |
| 119 | + steps: |
| 120 | + - uses: actions/checkout@v3 |
| 121 | + - name: Deploy to Render |
| 122 | + run: | |
| 123 | + curl -X POST https://api.render.com/deploy/srv-${{ secrets.RENDER_SERVICE_ID }}?key=${{ secrets.RENDER_API_KEY }} |
| 124 | +
|
| 125 | + deploy-railway: |
| 126 | + runs-on: ubuntu-latest |
| 127 | + steps: |
| 128 | + - uses: actions/checkout@v3 |
| 129 | + - name: Deploy to Railway |
| 130 | + uses: railway-app/action@v1 |
| 131 | + with: |
| 132 | + token: ${{ secrets.RAILWAY_TOKEN }} |
| 133 | + |
| 134 | + deploy-flyio: |
| 135 | + runs-on: ubuntu-latest |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v3 |
| 138 | + - name: Deploy to Fly.io |
| 139 | + uses: superfly/flyctl-actions@master |
| 140 | + with: |
| 141 | + args: "deploy --remote-only" |
| 142 | + env: |
| 143 | + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
| 144 | + |
| 145 | + deploy-vercel: |
| 146 | + runs-on: ubuntu-latest |
| 147 | + steps: |
| 148 | + - uses: actions/checkout@v3 |
| 149 | + - name: Deploy Dashboard to Vercel |
| 150 | + uses: vercel/action@master |
| 151 | + with: |
| 152 | + vercel-token: ${{ secrets.VERCEL_TOKEN }} |
| 153 | + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} |
| 154 | + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} |
| 155 | +``` |
| 156 | +
|
| 157 | +### 2. Add Secrets to GitHub |
| 158 | +
|
| 159 | +Visit: **Repository → Settings → Secrets and variables → Actions** |
| 160 | +
|
| 161 | +Click "New repository secret" and add: |
| 162 | +
|
| 163 | +``` |
| 164 | +RENDER_API_KEY = [from Render] |
| 165 | +RENDER_SERVICE_ID = [from Render] |
| 166 | +RAILWAY_TOKEN = [from Railway] |
| 167 | +RAILWAY_SERVICE = ai-downtime-api |
| 168 | +FLY_API_TOKEN = [from Fly.io] |
| 169 | +FLY_APP_NAME = ai-downtime-system |
| 170 | +VERCEL_TOKEN = [from Vercel] |
| 171 | +VERCEL_ORG_ID = [from Vercel] |
| 172 | +VERCEL_PROJECT_ID = [from Vercel] |
| 173 | +SLACK_WEBHOOK_URL = [from Slack] (optional) |
| 174 | +``` |
| 175 | + |
| 176 | +### 3. Test Workflow |
| 177 | + |
| 178 | +```bash |
| 179 | +# Push to main to trigger |
| 180 | +git push origin main |
| 181 | + |
| 182 | +# Or manually trigger |
| 183 | +# GitHub → Actions → Deploy to Cloud → Run workflow |
| 184 | +``` |
| 185 | + |
| 186 | +Monitor deployments: |
| 187 | +- **GitHub:** Repository → Actions tab |
| 188 | +- **Render:** Dashboard → Deploys tab |
| 189 | +- **Railway:** Dashboard → Deployments tab |
| 190 | +- **Fly.io:** flyctl status |
| 191 | +- **Vercel:** Dashboard → Deployments tab |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +## 🔒 Security Best Practices |
| 196 | + |
| 197 | +1. **Never commit secrets** to code |
| 198 | +2. **Use short-lived tokens** when available |
| 199 | +3. **Rotate tokens regularly** (monthly) |
| 200 | +4. **Limit token permissions** to only needed scopes |
| 201 | +5. **Enable branch protection** on main branch |
| 202 | +6. **Review deployment logs** for errors |
| 203 | +7. **Monitor API usage** on each platform |
| 204 | + |
| 205 | +### Secrets Rotation Checklist |
| 206 | +- [ ] Monthly: Rotate AWS keys |
| 207 | +- [ ] Monthly: Rotate Render API key |
| 208 | +- [ ] Monthly: Rotate Railway token |
| 209 | +- [ ] Monthly: Rotate Fly.io token |
| 210 | +- [ ] Quarterly: Rotate Vercel token |
| 211 | +- [ ] On team changes: Revoke old secrets |
| 212 | + |
| 213 | +--- |
| 214 | + |
| 215 | +## 📝 Creating API Tokens (Step-by-Step) |
| 216 | + |
| 217 | +### Render.com |
| 218 | +1. Log in → Account → API Tokens |
| 219 | +2. Click "Create new token" |
| 220 | +3. Give it a name: `GitHub Actions` |
| 221 | +4. Copy token |
| 222 | +5. In GitHub: Settings → Secrets → New secret |
| 223 | +6. Name: `RENDER_API_KEY` |
| 224 | +7. Value: [paste token] |
| 225 | +8. Click Add secret |
| 226 | + |
| 227 | +### Railway.app |
| 228 | +1. Log in → Account (avatar) → API Tokens |
| 229 | +2. Click "Generate token" |
| 230 | +3. Name: `GitHub Actions` |
| 231 | +4. Copy token |
| 232 | +5. In GitHub: Add as `RAILWAY_TOKEN` |
| 233 | + |
| 234 | +### Fly.io |
| 235 | +1. Log in → Account → Access Tokens |
| 236 | +2. Click "Create token" |
| 237 | +3. Name: `GitHub Actions` |
| 238 | +4. Copy token |
| 239 | +5. In GitHub: Add as `FLY_API_TOKEN` |
| 240 | + |
| 241 | +### Vercel |
| 242 | +1. Log in → Settings → Tokens |
| 243 | +2. Click "Create" |
| 244 | +3. Name: `GitHub Actions` |
| 245 | +4. Scope: Full Account |
| 246 | +5. Copy token |
| 247 | +6. In GitHub: Add as `VERCEL_TOKEN` |
| 248 | +7. Also add `VERCEL_ORG_ID` and `VERCEL_PROJECT_ID` from project settings |
| 249 | + |
| 250 | +### AWS |
| 251 | +1. AWS Console → IAM → Users |
| 252 | +2. Click "Create user" or select existing |
| 253 | +3. Permissions → Create access keys |
| 254 | +4. Copy Access Key ID and Secret Access Key |
| 255 | +5. In GitHub: |
| 256 | + - Add `AWS_ACCESS_KEY_ID` |
| 257 | + - Add `AWS_SECRET_ACCESS_KEY` |
| 258 | +6. **⚠️ CRITICAL:** Use an IAM user with minimal permissions, not root account |
| 259 | + |
| 260 | +--- |
| 261 | + |
| 262 | +## 🧪 Test Deployments |
| 263 | + |
| 264 | +### Test Render Deployment |
| 265 | +```bash |
| 266 | +curl -X POST https://api.render.com/deploy/srv-YOUR_SERVICE_ID?key=YOUR_API_KEY |
| 267 | +# Should return 200 with deployment info |
| 268 | +``` |
| 269 | + |
| 270 | +### Test Railway Deployment |
| 271 | +```bash |
| 272 | +railway status |
| 273 | +railway logs -s api |
| 274 | +``` |
| 275 | + |
| 276 | +### Test Fly.io Deployment |
| 277 | +```bash |
| 278 | +flyctl deploy |
| 279 | +flyctl status |
| 280 | +``` |
| 281 | + |
| 282 | +### Test Vercel Deployment |
| 283 | +```bash |
| 284 | +vercel --prod |
| 285 | +# Opens deployment in browser |
| 286 | +``` |
| 287 | + |
| 288 | +--- |
| 289 | + |
| 290 | +## 🚨 Troubleshooting |
| 291 | + |
| 292 | +### "Invalid token" error |
| 293 | +- Verify token is correct (check for extra spaces) |
| 294 | +- Verify token hasn't expired |
| 295 | +- Regenerate new token on platform |
| 296 | + |
| 297 | +### "Permission denied" error |
| 298 | +- Token scope too limited |
| 299 | +- Create token with full permissions |
| 300 | +- For AWS: IAM user needs sufficient permissions |
| 301 | + |
| 302 | +### Workflow not running |
| 303 | +- Check if main branch is protected |
| 304 | +- Verify workflow file syntax (`.github/workflows/deploy-cloud.yml`) |
| 305 | +- Manual trigger: Actions → Deploy to Cloud → Run workflow |
| 306 | + |
| 307 | +### Deployment stuck |
| 308 | +- Check platform logs |
| 309 | +- Verify database connection |
| 310 | +- Check environment variables |
| 311 | +- Review application logs |
| 312 | + |
| 313 | +--- |
| 314 | + |
| 315 | +## 📊 Recommended Setup |
| 316 | + |
| 317 | +### Minimal (Render only) |
| 318 | +``` |
| 319 | +RENDER_API_KEY |
| 320 | +RENDER_SERVICE_ID |
| 321 | +``` |
| 322 | + |
| 323 | +### Standard (Render + Vercel) |
| 324 | +``` |
| 325 | +RENDER_API_KEY |
| 326 | +RENDER_SERVICE_ID |
| 327 | +VERCEL_TOKEN |
| 328 | +VERCEL_ORG_ID |
| 329 | +VERCEL_PROJECT_ID |
| 330 | +``` |
| 331 | + |
| 332 | +### Complete (All platforms) |
| 333 | +``` |
| 334 | +RENDER_API_KEY |
| 335 | +RENDER_SERVICE_ID |
| 336 | +RAILWAY_TOKEN |
| 337 | +RAILWAY_SERVICE |
| 338 | +FLY_API_TOKEN |
| 339 | +FLY_APP_NAME |
| 340 | +VERCEL_TOKEN |
| 341 | +VERCEL_ORG_ID |
| 342 | +VERCEL_PROJECT_ID |
| 343 | +AWS_ACCESS_KEY_ID |
| 344 | +AWS_SECRET_ACCESS_KEY |
| 345 | +SLACK_WEBHOOK_URL (optional) |
| 346 | +``` |
| 347 | + |
| 348 | +--- |
| 349 | + |
| 350 | +## ✅ Verification Checklist |
| 351 | + |
| 352 | +- [ ] Created secrets in GitHub |
| 353 | +- [ ] Verified each secret is spelled correctly |
| 354 | +- [ ] Tested each platform's API token works |
| 355 | +- [ ] Committed `.github/workflows/deploy-cloud.yml` |
| 356 | +- [ ] Pushed to main branch |
| 357 | +- [ ] Checked Actions tab for successful runs |
| 358 | +- [ ] Verified deployments on each platform |
| 359 | + |
| 360 | +--- |
| 361 | + |
| 362 | +## 🔗 Quick Links |
| 363 | + |
| 364 | +- [GitHub Secrets Documentation](https://docs.github.com/en/actions/security-guides/encrypted-secrets) |
| 365 | +- [Render API Documentation](https://render.com/docs/api) |
| 366 | +- [Railway Documentation](https://docs.railway.app) |
| 367 | +- [Fly.io Documentation](https://fly.io/docs) |
| 368 | +- [Vercel Documentation](https://vercel.com/docs) |
| 369 | + |
| 370 | +--- |
| 371 | + |
| 372 | +## 💡 Pro Tips |
| 373 | + |
| 374 | +1. **Use environments**: Create dev/staging/prod environments with different secrets |
| 375 | +2. **Auto-deploy on tags**: Modify workflow to deploy on releases |
| 376 | +3. **Slack notifications**: Add webhook step to notify on deployment |
| 377 | +4. **Rollback automation**: Create workflow for rollbacks |
| 378 | +5. **Monitor health**: Add post-deployment health checks |
| 379 | + |
| 380 | +Example health check in workflow: |
| 381 | +```yaml |
| 382 | +- name: Verify Deployment |
| 383 | + run: | |
| 384 | + sleep 30 |
| 385 | + curl -f https://your-api.onrender.com/health || exit 1 |
| 386 | +``` |
| 387 | +
|
| 388 | +--- |
| 389 | +
|
| 390 | +**All set!** Your CI/CD pipeline is ready to automatically deploy to multiple cloud platforms. |
| 391 | +
|
| 392 | +Push to main and watch it deploy! 🚀 |
0 commit comments