|
| 1 | +# GitHub Secrets Setup Guide |
| 2 | + |
| 3 | +There are 4 ways to add the required secrets to your GitHub repository. Pick the one that works best for you. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Method 1: Manual Web UI (Easiest, 5 minutes) |
| 8 | + |
| 9 | +**No tools required. Just a browser.** |
| 10 | + |
| 11 | +### Steps |
| 12 | + |
| 13 | +1. Go to: `https://github.com/ciscoittech/binary-math-system/settings/secrets/actions` |
| 14 | + |
| 15 | +2. Click **"New repository secret"** button (top right) |
| 16 | + |
| 17 | +3. For each of these 5 secrets, follow the pattern: |
| 18 | + - Click "New repository secret" |
| 19 | + - Enter **Name** (from list below) |
| 20 | + - Enter **Value** (from sources below) |
| 21 | + - Click "Add secret" |
| 22 | + |
| 23 | +### Secrets to Add |
| 24 | + |
| 25 | +#### 1. `CLOUDFLARE_API_TOKEN` |
| 26 | +- **Where to get**: https://dash.cloudflare.com/profile/api-tokens |
| 27 | +- **How**: |
| 28 | + - Click "Create Token" |
| 29 | + - Use template: "Edit Cloudflare Workers" |
| 30 | + - Grant all suggested permissions |
| 31 | + - Copy the token |
| 32 | + |
| 33 | +#### 2. `CLOUDFLARE_ACCOUNT_ID` |
| 34 | +- **Where to get**: https://dash.cloudflare.com |
| 35 | +- **How**: |
| 36 | + - Right sidebar under "Account Details" |
| 37 | + - Copy "Account ID" |
| 38 | + |
| 39 | +#### 3. `TURSO_URL` |
| 40 | +- **Where to get**: https://turso.io/dashboard |
| 41 | +- **How**: |
| 42 | + - Click your database |
| 43 | + - Copy connection URL |
| 44 | + - Format: `libsql://your-db.turso.io` |
| 45 | + |
| 46 | +#### 4. `TURSO_AUTH_TOKEN` |
| 47 | +- **Where to get**: https://turso.io/dashboard |
| 48 | +- **How**: |
| 49 | + - Click your database |
| 50 | + - Copy auth token |
| 51 | + |
| 52 | +#### 5. `OPENROUTER_API_KEY` (Optional) |
| 53 | +- **Where to get**: https://openrouter.ai/keys |
| 54 | +- **How**: |
| 55 | + - Create API key |
| 56 | + - Copy the key |
| 57 | +- **Note**: Only needed if using AI features |
| 58 | + |
| 59 | +### Verify |
| 60 | + |
| 61 | +Go to `https://github.com/ciscoittech/binary-math-system/settings/secrets/actions` |
| 62 | + |
| 63 | +You should see all 5 secrets listed (values are hidden for security). |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Method 2: GitHub CLI (Fast, 2 minutes) |
| 68 | + |
| 69 | +**Requires**: GitHub CLI installed (`gh`) and authenticated |
| 70 | + |
| 71 | +### Install & Authenticate |
| 72 | + |
| 73 | +```bash |
| 74 | +# Install if you haven't |
| 75 | +brew install gh |
| 76 | + |
| 77 | +# Authenticate |
| 78 | +gh auth login |
| 79 | +# Follow prompts (choose HTTPS, create token if needed) |
| 80 | +``` |
| 81 | + |
| 82 | +### Run Our Script |
| 83 | + |
| 84 | +```bash |
| 85 | +# Make executable |
| 86 | +chmod +x setup-secrets.sh |
| 87 | + |
| 88 | +# Run the script |
| 89 | +./setup-secrets.sh |
| 90 | +``` |
| 91 | + |
| 92 | +The script will: |
| 93 | +1. Prompt for each secret value |
| 94 | +2. Use `gh secret set` to add them |
| 95 | +3. Confirm each one |
| 96 | + |
| 97 | +### Verify |
| 98 | + |
| 99 | +```bash |
| 100 | +gh secret list --repo ciscoittech/binary-math-system |
| 101 | +``` |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## Method 3: Python Script (Automated, 2 minutes) |
| 106 | + |
| 107 | +**Requires**: Python 3.7+, `requests`, `pynacl` libraries |
| 108 | + |
| 109 | +### Setup |
| 110 | + |
| 111 | +```bash |
| 112 | +# Install dependencies |
| 113 | +pip install requests pynacl |
| 114 | + |
| 115 | +# Make executable |
| 116 | +chmod +x setup-secrets.py |
| 117 | + |
| 118 | +# Run |
| 119 | +python3 setup-secrets.py |
| 120 | +``` |
| 121 | + |
| 122 | +The script will: |
| 123 | +1. Use GitHub API to encrypt secrets |
| 124 | +2. Prompt for each value |
| 125 | +3. Set them directly via API |
| 126 | + |
| 127 | +### What It Does |
| 128 | + |
| 129 | +- Authenticates via `gh` CLI |
| 130 | +- Gets public key from GitHub for encryption |
| 131 | +- Encrypts each secret with public key |
| 132 | +- Posts to GitHub API |
| 133 | +- Verifies setup |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## Method 4: Raw GitHub API (Advanced) |
| 138 | + |
| 139 | +**For complete control / CI environments** |
| 140 | + |
| 141 | +### Prerequisites |
| 142 | + |
| 143 | +```bash |
| 144 | +# Get your GitHub token |
| 145 | +gh auth token > /tmp/github_token.txt |
| 146 | + |
| 147 | +# Or create a Personal Access Token: |
| 148 | +# Settings → Developer settings → Personal access tokens → Tokens (classic) |
| 149 | +# Scopes: repo, admin:repo_hook |
| 150 | +``` |
| 151 | + |
| 152 | +### Manual API Calls |
| 153 | + |
| 154 | +```bash |
| 155 | +REPO="ciscoittech/binary-math-system" |
| 156 | +TOKEN="ghp_xxxxxxxxxxxx" |
| 157 | + |
| 158 | +# Get public key |
| 159 | +curl -X GET \ |
| 160 | + -H "Authorization: Bearer $TOKEN" \ |
| 161 | + https://api.github.com/repos/$REPO/actions/secrets/public-key |
| 162 | + |
| 163 | +# Set secret (requires encryption - see below) |
| 164 | +curl -X PUT \ |
| 165 | + -H "Authorization: Bearer $TOKEN" \ |
| 166 | + -H "Content-Type: application/json" \ |
| 167 | + https://api.github.com/repos/$REPO/actions/secrets/SECRET_NAME \ |
| 168 | + -d '{ |
| 169 | + "encrypted_value": "base64_encrypted_value", |
| 170 | + "key_id": "key_id_from_above" |
| 171 | + }' |
| 172 | +``` |
| 173 | + |
| 174 | +**Note**: Requires NaCl encryption. Easier to use Method 2 or 3. |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +## Recommended: Use Method 1 or 2 |
| 179 | + |
| 180 | +### If you like clicking: |
| 181 | +→ **Method 1** (Web UI) |
| 182 | + |
| 183 | +### If you like terminals: |
| 184 | +→ **Method 2** (GitHub CLI) |
| 185 | + |
| 186 | +### If you want it fully automated: |
| 187 | +→ **Method 3** (Python script) |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## Troubleshooting |
| 192 | + |
| 193 | +### "gh: command not found" |
| 194 | +```bash |
| 195 | +# Install GitHub CLI |
| 196 | +brew install gh |
| 197 | + |
| 198 | +# Then authenticate |
| 199 | +gh auth login |
| 200 | +``` |
| 201 | + |
| 202 | +### "Not authenticated with GitHub" |
| 203 | +```bash |
| 204 | +# Authenticate |
| 205 | +gh auth login |
| 206 | + |
| 207 | +# Verify |
| 208 | +gh auth status |
| 209 | +``` |
| 210 | + |
| 211 | +### "Python: No module named requests" |
| 212 | +```bash |
| 213 | +pip install requests pynacl |
| 214 | +``` |
| 215 | + |
| 216 | +### "401 Unauthorized" (API method) |
| 217 | +```bash |
| 218 | +# Your token may have expired |
| 219 | +gh auth login # Re-authenticate |
| 220 | + |
| 221 | +# Or create new Personal Access Token: |
| 222 | +# https://github.com/settings/tokens/new |
| 223 | +# Scopes: repo, admin:repo_hook |
| 224 | +``` |
| 225 | + |
| 226 | +### Secrets not showing up |
| 227 | +- Refresh the GitHub page |
| 228 | +- Wait a few seconds (GitHub caches) |
| 229 | +- Verify you're in the right repo settings |
| 230 | + |
| 231 | +--- |
| 232 | + |
| 233 | +## Verify Setup |
| 234 | + |
| 235 | +After adding secrets, verify they're there: |
| 236 | + |
| 237 | +### Via Web UI |
| 238 | +- Go to `https://github.com/ciscoittech/binary-math-system/settings/secrets/actions` |
| 239 | +- You should see all 5 secrets listed |
| 240 | + |
| 241 | +### Via CLI |
| 242 | +```bash |
| 243 | +gh secret list --repo ciscoittech/binary-math-system |
| 244 | +``` |
| 245 | + |
| 246 | +Expected output: |
| 247 | +``` |
| 248 | +CLOUDFLARE_API_TOKEN |
| 249 | +CLOUDFLARE_ACCOUNT_ID |
| 250 | +TURSO_URL |
| 251 | +TURSO_AUTH_TOKEN |
| 252 | +OPENROUTER_API_KEY |
| 253 | +``` |
| 254 | + |
| 255 | +--- |
| 256 | + |
| 257 | +## Next Steps |
| 258 | + |
| 259 | +After secrets are set: |
| 260 | + |
| 261 | +1. **Trigger deployment** |
| 262 | + ```bash |
| 263 | + git push origin main |
| 264 | + ``` |
| 265 | + |
| 266 | +2. **Watch GitHub Actions** |
| 267 | + ```bash |
| 268 | + https://github.com/ciscoittech/binary-math-system/actions |
| 269 | + ``` |
| 270 | + |
| 271 | +3. **Monitor logs** |
| 272 | + ```bash |
| 273 | + gh run list --repo ciscoittech/binary-math-system |
| 274 | + ``` |
| 275 | + |
| 276 | +--- |
| 277 | + |
| 278 | +## Security Notes |
| 279 | + |
| 280 | +- ✅ Secrets are **encrypted** at rest in GitHub |
| 281 | +- ✅ Secrets are **never logged** in workflow runs |
| 282 | +- ✅ Only available to **authenticated deployments** |
| 283 | +- ✅ Not visible in pull requests or forks |
| 284 | +- ✅ Can be **rotated** anytime |
| 285 | + |
| 286 | +--- |
| 287 | + |
| 288 | +## Secret Rotation |
| 289 | + |
| 290 | +To update a secret (e.g., if token expires): |
| 291 | + |
| 292 | +### Method 1 (Web UI) |
| 293 | +1. Go to Settings → Secrets |
| 294 | +2. Find the secret |
| 295 | +3. Click "Update" |
| 296 | +4. Enter new value |
| 297 | +5. Click "Update secret" |
| 298 | + |
| 299 | +### Method 2 (CLI) |
| 300 | +```bash |
| 301 | +gh secret set SECRET_NAME --repo ciscoittech/binary-math-system |
| 302 | +# Paste new value when prompted |
| 303 | +``` |
| 304 | + |
| 305 | +--- |
| 306 | + |
| 307 | +**Choose a method above and let's get your secrets set up!** |
0 commit comments