|
| 1 | +# GitHub Secrets Setup |
| 2 | + |
| 3 | +This document explains how to configure secrets for the Singularity-ng organization. |
| 4 | + |
| 5 | +## Recommended Setup: Organization-Level Secrets |
| 6 | + |
| 7 | +Add these secrets at the **organization level** to share across all repositories: |
| 8 | + |
| 9 | +### Required Secrets |
| 10 | + |
| 11 | +#### 1. CACHIX_AUTH_TOKEN |
| 12 | +**What**: Authentication token for Cachix binary cache |
| 13 | +**Where to get**: https://app.cachix.org/personal-auth-tokens |
| 14 | +**Used by**: |
| 15 | +- `.github/workflows/nix-ci.yml` |
| 16 | +- `.github/workflows/cachix-push.yml` |
| 17 | + |
| 18 | +**Setup**: |
| 19 | +1. Go to https://app.cachix.org |
| 20 | +2. Sign in with GitHub |
| 21 | +3. Navigate to Personal Auth Tokens |
| 22 | +4. Create new token with push access to `mikkihugo` cache |
| 23 | +5. Copy token |
| 24 | + |
| 25 | +#### 2. CLAUDE_CODE_OAUTH_TOKEN |
| 26 | +**What**: OAuth token for Claude Code GitHub integration |
| 27 | +**Where to get**: https://claude.ai (when setting up GitHub integration) |
| 28 | +**Used by**: |
| 29 | +- `.github/workflows/claude-review.yml` |
| 30 | +- `.github/workflows/claude.yml` |
| 31 | + |
| 32 | +**Setup**: |
| 33 | +1. Install Claude Code GitHub App |
| 34 | +2. Generate OAuth token from Claude settings |
| 35 | +3. Copy token |
| 36 | + |
| 37 | +#### 3. ORG_GITHUB_TOKEN (Optional but recommended) |
| 38 | +**What**: GitHub Personal Access Token with org permissions |
| 39 | +**Where to get**: https://github.com/settings/tokens |
| 40 | +**Used by**: |
| 41 | +- `.github/workflows/claude-review.yml` (for auto-merge) |
| 42 | + |
| 43 | +**Setup**: |
| 44 | +1. Create fine-grained PAT or classic PAT |
| 45 | +2. Scopes needed: `repo`, `workflow`, `write:packages` |
| 46 | +3. Copy token |
| 47 | + |
| 48 | +**Note**: Falls back to `GITHUB_TOKEN` if not set, but has limited permissions. |
| 49 | + |
| 50 | +#### 4. ANTHROPIC_API_KEY (Optional) |
| 51 | +**What**: Anthropic API key for Claude API access |
| 52 | +**Where to get**: https://console.anthropic.com |
| 53 | +**Used by**: |
| 54 | +- `.github/workflows/auto-pr.yml` (enhanced PR descriptions) |
| 55 | + |
| 56 | +**Setup**: |
| 57 | +1. Go to Anthropic Console |
| 58 | +2. Create API key |
| 59 | +3. Copy key |
| 60 | + |
| 61 | +#### 5. CODECOV_TOKEN (Optional) |
| 62 | +**What**: Codecov project token for coverage uploads |
| 63 | +**Where to get**: https://codecov.io |
| 64 | +**Used by**: |
| 65 | +- `.github/workflows/ci.yml` (coverage job) |
| 66 | + |
| 67 | +**Setup**: |
| 68 | +1. Enable repo on Codecov |
| 69 | +2. Get token from repo settings |
| 70 | +3. Copy token |
| 71 | + |
| 72 | +### Per-Repository Secrets |
| 73 | + |
| 74 | +These should be added per-repository as needed: |
| 75 | + |
| 76 | +#### HEX_API_KEY |
| 77 | +**What**: Hex.pm publishing token |
| 78 | +**Where to get**: https://hex.pm/settings/keys |
| 79 | +**Used by**: |
| 80 | +- `.github/workflows/publish.yml` |
| 81 | + |
| 82 | +**Setup** (per Elixir repo): |
| 83 | +1. Login to Hex.pm |
| 84 | +2. Generate publishing key |
| 85 | +3. Add to repository secrets |
| 86 | + |
| 87 | +## Adding Organization Secrets |
| 88 | + |
| 89 | +### Step 1: Navigate to Organization Settings |
| 90 | + |
| 91 | +``` |
| 92 | +https://github.com/organizations/Singularity-ng/settings/secrets/actions |
| 93 | +``` |
| 94 | + |
| 95 | +Or: |
| 96 | +1. Go to https://github.com/Singularity-ng |
| 97 | +2. Click "Settings" |
| 98 | +3. Sidebar: "Secrets and variables" → "Actions" |
| 99 | + |
| 100 | +### Step 2: Add Secrets |
| 101 | + |
| 102 | +For each secret: |
| 103 | + |
| 104 | +1. Click "New organization secret" |
| 105 | +2. Enter **Name** (exactly as shown above, case-sensitive) |
| 106 | +3. Enter **Value** (the token/key) |
| 107 | +4. **Repository access**: Choose one: |
| 108 | + - ✅ **All repositories** (recommended for shared secrets) |
| 109 | + - Private repositories only |
| 110 | + - Selected repositories (choose specific repos) |
| 111 | + |
| 112 | +### Step 3: Verify |
| 113 | + |
| 114 | +After adding, workflows will automatically use organization secrets. |
| 115 | + |
| 116 | +No code changes needed - workflows already reference these secrets! |
| 117 | + |
| 118 | +## Security Best Practices |
| 119 | + |
| 120 | +### Secret Rotation |
| 121 | + |
| 122 | +Rotate secrets regularly: |
| 123 | +- CACHIX_AUTH_TOKEN: Annually |
| 124 | +- CLAUDE_CODE_OAUTH_TOKEN: When compromised or annually |
| 125 | +- GITHUB_TOKEN: Auto-rotates (don't store) |
| 126 | +- API keys: Every 6-12 months |
| 127 | + |
| 128 | +### Access Control |
| 129 | + |
| 130 | +For sensitive secrets (like HEX_API_KEY): |
| 131 | +- Use "Selected repositories" access |
| 132 | +- Only give to repos that need it |
| 133 | +- Review access quarterly |
| 134 | + |
| 135 | +### Monitoring |
| 136 | + |
| 137 | +Check secret usage: |
| 138 | +1. Go to organization secrets page |
| 139 | +2. Click on a secret |
| 140 | +3. View "Last used" timestamp |
| 141 | +4. Review which repos are using it |
| 142 | + |
| 143 | +## Troubleshooting |
| 144 | + |
| 145 | +### "Secret not found" error |
| 146 | + |
| 147 | +1. Check secret name is exactly correct (case-sensitive) |
| 148 | +2. Verify workflow has access to org secrets |
| 149 | +3. Check repository access settings for the secret |
| 150 | + |
| 151 | +### Permission denied |
| 152 | + |
| 153 | +1. Verify `CACHIX_AUTH_TOKEN` has push permissions |
| 154 | +2. Check `ORG_GITHUB_TOKEN` has required scopes |
| 155 | +3. Ensure secrets aren't expired |
| 156 | + |
| 157 | +### Cache not working |
| 158 | + |
| 159 | +1. Verify `CACHIX_AUTH_TOKEN` is set |
| 160 | +2. Check cache name matches: `mikkihugo` |
| 161 | +3. Test with: `cachix push mikkihugo result` |
| 162 | + |
| 163 | +## Testing Secrets |
| 164 | + |
| 165 | +After adding org secrets, test with: |
| 166 | + |
| 167 | +```bash |
| 168 | +# Trigger a workflow manually |
| 169 | +gh workflow run nix-ci.yml |
| 170 | + |
| 171 | +# Check workflow logs |
| 172 | +gh run list --workflow=nix-ci.yml |
| 173 | +gh run view <run-id> --log |
| 174 | +``` |
| 175 | + |
| 176 | +Look for: |
| 177 | +- ✅ "Setup Cachix" step succeeds |
| 178 | +- ✅ "Push to Cachix" completes without auth errors |
| 179 | +- ✅ No "secret not found" errors |
| 180 | + |
| 181 | +## Enterprise Secrets |
| 182 | + |
| 183 | +If you have **GitHub Enterprise**, you can set enterprise-level secrets: |
| 184 | + |
| 185 | +``` |
| 186 | +https://github.com/enterprises/YOUR_ENTERPRISE/settings/secrets/actions |
| 187 | +``` |
| 188 | + |
| 189 | +Enterprise secrets cascade to: |
| 190 | +- All organizations in the enterprise |
| 191 | +- All repositories in those organizations |
| 192 | + |
| 193 | +Use enterprise secrets for: |
| 194 | +- Company-wide infrastructure (Cachix, monitoring, etc.) |
| 195 | +- Security tools (Sobelow, SAST, etc.) |
| 196 | +- Common CI/CD tools |
| 197 | + |
| 198 | +## Secret Priority |
| 199 | + |
| 200 | +GitHub checks secrets in this order: |
| 201 | +1. Repository secrets (highest priority) |
| 202 | +2. Organization secrets |
| 203 | +3. Enterprise secrets |
| 204 | + |
| 205 | +This allows per-repo overrides when needed. |
| 206 | + |
| 207 | +## Summary Checklist |
| 208 | + |
| 209 | +Organization-level (add once): |
| 210 | +- [ ] CACHIX_AUTH_TOKEN |
| 211 | +- [ ] CLAUDE_CODE_OAUTH_TOKEN |
| 212 | +- [ ] ORG_GITHUB_TOKEN (optional) |
| 213 | +- [ ] ANTHROPIC_API_KEY (optional) |
| 214 | +- [ ] CODECOV_TOKEN (optional) |
| 215 | + |
| 216 | +Repository-level (per Elixir repo): |
| 217 | +- [ ] HEX_API_KEY |
| 218 | + |
| 219 | +After setup: |
| 220 | +- [ ] Test nix-ci.yml workflow |
| 221 | +- [ ] Verify Cachix pushes work |
| 222 | +- [ ] Test Claude workflows (@claude mention) |
| 223 | +- [ ] Document any repo-specific secrets |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +**Need help?** Check GitHub docs: |
| 228 | +https://docs.github.com/en/actions/security-guides/encrypted-secrets |
0 commit comments