Skip to content

Commit b0e50f7

Browse files
bhuntclaude
andcommitted
fix: remove GitHub CLI dependency from secrets setup
- setup-secrets.sh: Now uses curl + GitHub API directly (no gh CLI) - setup-secrets.py: Uses requests + GitHub API directly (no gh CLI) - GITHUB_SECRETS_SETUP.md: Updated docs to reflect pure API approach All methods now work without GitHub CLI: - Method 1: Web UI (manual, no tools) - Method 2: Bash script (curl + python) - Method 3: Python script (requests + python) - Method 4: Raw API (curl + jq) Each method handles NaCl encryption for GitHub API. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 764162d commit b0e50f7

3 files changed

Lines changed: 260 additions & 151 deletions

File tree

GITHUB_SECRETS_SETUP.md

Lines changed: 114 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -64,73 +64,93 @@ You should see all 5 secrets listed (values are hidden for security).
6464

6565
---
6666

67-
## Method 2: GitHub CLI (Fast, 2 minutes)
67+
## Method 2: Bash Script (Fast, 2 minutes)
6868

69-
**Requires**: GitHub CLI installed (`gh`) and authenticated
69+
**Requires**: curl, python3, PyNaCl (no GitHub CLI needed!)
7070

71-
### Install & Authenticate
71+
### Setup
7272

7373
```bash
74-
# Install if you haven't
75-
brew install gh
74+
# Install dependencies
75+
pip install pynacl
7676

77-
# Authenticate
78-
gh auth login
79-
# Follow prompts (choose HTTPS, create token if needed)
77+
# Create GitHub Personal Access Token:
78+
# 1. Go to: https://github.com/settings/tokens/new
79+
# 2. Name: "Binary Math Secrets"
80+
# 3. Scopes: repo, admin:repo_hook
81+
# 4. Generate and copy token
8082
```
8183

82-
### Run Our Script
84+
### Run the Script
8385

8486
```bash
85-
# Make executable
86-
chmod +x setup-secrets.sh
87+
# Set your token in environment
88+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
8789

88-
# Run the script
90+
# Make executable and run
91+
chmod +x setup-secrets.sh
8992
./setup-secrets.sh
9093
```
9194

9295
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+
1. Validate your token
97+
2. Fetch GitHub's public key
98+
3. Prompt for each secret value
99+
4. Encrypt with PyNaCl
100+
5. POST directly to GitHub API
101+
6. Confirm each one
96102

97-
### Verify
103+
### What It Does (Under the hood)
98104

99-
```bash
100-
gh secret list --repo ciscoittech/binary-math-system
101-
```
105+
- ✅ Uses curl for HTTP calls (no CLI)
106+
- ✅ Uses Python + PyNaCl for encryption
107+
- ✅ Directly calls GitHub API endpoints
108+
- ✅ Completely CLI-free approach
102109

103110
---
104111

105-
## Method 3: Python Script (Automated, 2 minutes)
112+
## Method 3: Python Script (Fully Automated)
106113

107-
**Requires**: Python 3.7+, `requests`, `pynacl` libraries
114+
**Requires**: Python 3.7+, `requests`, `pynacl` libraries (no CLI)
108115

109116
### Setup
110117

111118
```bash
112119
# Install dependencies
113120
pip install requests pynacl
114121

115-
# Make executable
116-
chmod +x setup-secrets.py
122+
# Create GitHub Personal Access Token:
123+
# 1. Go to: https://github.com/settings/tokens/new
124+
# 2. Name: "Binary Math Secrets"
125+
# 3. Scopes: repo, admin:repo_hook
126+
# 4. Generate and copy token
127+
```
128+
129+
### Run
117130

118-
# Run
131+
```bash
132+
# Set your token
133+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
134+
135+
# Run the script
136+
chmod +x setup-secrets.py
119137
python3 setup-secrets.py
120138
```
121139

122140
The script will:
123-
1. Use GitHub API to encrypt secrets
124-
2. Prompt for each value
125-
3. Set them directly via API
141+
1. Get your token from environment
142+
2. Fetch GitHub's public key via API
143+
3. Prompt for each secret value
144+
4. Encrypt with PyNaCl
145+
5. POST directly to GitHub API
146+
6. Verify each one
126147

127148
### What It Does
128149

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
150+
- ✅ Uses requests for HTTP calls (no CLI)
151+
- ✅ Uses PyNaCl for encryption
152+
- ✅ Directly calls GitHub API endpoints
153+
- ✅ Completely CLI-free approach
134154

135155
---
136156

@@ -175,52 +195,55 @@ curl -X PUT \
175195

176196
---
177197

178-
## Recommended: Use Method 1 or 2
198+
## Recommended: Use Method 1, 2, or 3
179199

180-
### If you like clicking:
181-
**Method 1** (Web UI)
200+
### If you prefer clicking (easiest):
201+
**Method 1** (Web UI - no tools needed)
182202

183-
### If you like terminals:
184-
**Method 2** (GitHub CLI)
203+
### If you prefer shell (fast):
204+
**Method 2** (Bash script - no GitHub CLI)
185205

186-
### If you want it fully automated:
187-
**Method 3** (Python script)
206+
### If you want full automation:
207+
**Method 3** (Python script - no GitHub CLI)
188208

189209
---
190210

191211
## Troubleshooting
192212

193-
### "gh: command not found"
213+
### "GITHUB_TOKEN not set"
194214
```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
215+
# Create Personal Access Token at:
216+
# https://github.com/settings/tokens/new
217+
#
218+
# Scopes: repo, admin:repo_hook
219+
#
220+
# Then set it:
221+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
206222

207223
# Verify
208-
gh auth status
224+
echo $GITHUB_TOKEN # Should show your token
209225
```
210226

211-
### "Python: No module named requests"
227+
### "No module named requests" or "No module named nacl"
212228
```bash
213229
pip install requests pynacl
214230
```
215231

216-
### "401 Unauthorized" (API method)
232+
### "401 Unauthorized"
217233
```bash
218-
# Your token may have expired
219-
gh auth login # Re-authenticate
234+
# Your token may have expired or wrong scopes
235+
# Create new at: https://github.com/settings/tokens/new
236+
# Make sure scopes include: repo, admin:repo_hook
220237

221-
# Or create new Personal Access Token:
222-
# https://github.com/settings/tokens/new
223-
# Scopes: repo, admin:repo_hook
238+
# Set it again
239+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
240+
```
241+
242+
### "Failed to get public key"
243+
```bash
244+
# Your token may not have correct permissions
245+
# Check it has: repo, admin:repo_hook scopes
246+
# Create new at: https://github.com/settings/tokens/new
224247
```
225248

226249
### Secrets not showing up
@@ -234,22 +257,17 @@ gh auth login # Re-authenticate
234257

235258
After adding secrets, verify they're there:
236259

237-
### Via Web UI
260+
### Via Web UI (Best)
238261
- Go to `https://github.com/ciscoittech/binary-math-system/settings/secrets/actions`
239-
- You should see all 5 secrets listed
262+
- You should see all 5 secrets listed (values are hidden)
240263

241-
### Via CLI
242-
```bash
243-
gh secret list --repo ciscoittech/binary-math-system
264+
Expected to see:
244265
```
245-
246-
Expected output:
247-
```
248-
CLOUDFLARE_API_TOKEN
249-
CLOUDFLARE_ACCOUNT_ID
250-
TURSO_URL
251-
TURSO_AUTH_TOKEN
252-
OPENROUTER_API_KEY
266+
CLOUDFLARE_API_TOKEN Updated X minutes ago
267+
CLOUDFLARE_ACCOUNT_ID Updated X minutes ago
268+
TURSO_URL Updated X minutes ago
269+
TURSO_AUTH_TOKEN Updated X minutes ago
270+
OPENROUTER_API_KEY Updated X minutes ago (optional)
253271
```
254272

255273
---
@@ -264,13 +282,17 @@ After secrets are set:
264282
```
265283

266284
2. **Watch GitHub Actions**
267-
```bash
268-
https://github.com/ciscoittech/binary-math-system/actions
269-
```
285+
- Go to: `https://github.com/ciscoittech/binary-math-system/actions`
286+
- Should see workflow running
287+
- Tests will run, then deploy to Cloudflare
270288

271-
3. **Monitor logs**
289+
3. **Verify deployment**
272290
```bash
273-
gh run list --repo ciscoittech/binary-math-system
291+
# Check API is live
292+
curl https://api.binarymath.dev/health
293+
294+
# Visit web app
295+
https://binary-math.pages.dev
274296
```
275297

276298
---
@@ -289,17 +311,23 @@ After secrets are set:
289311

290312
To update a secret (e.g., if token expires):
291313

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"
314+
### Method 1 (Web UI - Easiest)
315+
1. Go to `https://github.com/ciscoittech/binary-math-system/settings/secrets/actions`
316+
2. Find the secret you want to update
317+
3. Click the secret name
318+
4. Click "Update"
319+
5. Enter new value
320+
6. Click "Update secret"
298321

299-
### Method 2 (CLI)
322+
### Method 2 (Script)
300323
```bash
301-
gh secret set SECRET_NAME --repo ciscoittech/binary-math-system
302-
# Paste new value when prompted
324+
# Set your token
325+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
326+
327+
# Update one secret
328+
pip install requests pynacl
329+
python3 setup-secrets.py
330+
# Just enter the value for the one you want to update, skip others
303331
```
304332

305333
---

setup-secrets.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import sys
1010
import json
1111
import base64
12-
import subprocess
1312
from pathlib import Path
1413

1514
try:
@@ -19,6 +18,13 @@
1918
print("Install with: pip install requests")
2019
sys.exit(1)
2120

21+
try:
22+
from nacl import public, utils
23+
except ImportError:
24+
print("❌ PyNaCl library not installed")
25+
print("Install with: pip install pynacl")
26+
sys.exit(1)
27+
2228
# Configuration
2329
REPO = "ciscoittech/binary-math-system"
2430
GITHUB_API = "https://api.github.com"
@@ -60,20 +66,22 @@
6066

6167

6268
def get_github_token():
63-
"""Get GitHub token from gh CLI"""
64-
try:
65-
result = subprocess.run(
66-
["gh", "auth", "token"],
67-
capture_output=True,
68-
text=True,
69-
check=True,
70-
)
71-
return result.stdout.strip()
72-
except (FileNotFoundError, subprocess.CalledProcessError):
73-
print("❌ GitHub CLI not installed or not authenticated")
74-
print("Install: https://cli.github.com")
75-
print("Or set GITHUB_TOKEN environment variable")
69+
"""Get GitHub token from environment variable"""
70+
token = os.getenv("GITHUB_TOKEN")
71+
if not token:
72+
print("❌ GITHUB_TOKEN environment variable not set")
73+
print()
74+
print("Create a Personal Access Token:")
75+
print(" 1. Go to: https://github.com/settings/tokens/new")
76+
print(" 2. Name: 'Binary Math Secrets'")
77+
print(" 3. Scopes: repo, admin:repo_hook")
78+
print(" 4. Generate token and copy it")
79+
print()
80+
print("Then run:")
81+
print(" export GITHUB_TOKEN=ghp_xxxxxxxxxxxx")
82+
print(" python3 setup-secrets.py")
7683
return None
84+
return token
7785

7886

7987
def get_public_key(token):

0 commit comments

Comments
 (0)