gh-secrets-cli
v1.0.1
Published
CLI tool to easily manage GitHub Actions secrets from your local machine
Downloads
185
Maintainers
Readme
GH Secrets CLI
A local CLI tool to easily manage GitHub Actions secrets without using the web interface.
Features
- ✅ Two Authentication Methods:
- Personal Access Token (PAT) - Simple and quick
- OAuth Device Flow - Browser-based with custom scopes
- ✅ Manage secrets for personal repositories
- ✅ Manage secrets for organization repositories
- ✅ List all secrets in a repository
- ✅ Add/Update individual secrets
- ✅ Batch upload secrets from
.envfiles - ✅ Delete secrets
- ✅ No database - completely local
- ✅ Secure password masking for sensitive input
Installation
For End Users
Option 1: Using npx (No installation needed)
npx gh-secrets-cliOption 2: Global Installation
npm install -g gh-secrets-cliThen run anywhere:
gh-secret-cliFor Development
# Clone the repository
git clone https://github.com/jbacule/gh-secrets-cli.git
cd gh-secrets-cli
# Install dependencies
pnpm install
# Run in development mode
pnpm start
# Build for production
pnpm buildUsage
# Start the CLI
pnpm startPrerequisites
- Node.js 18+ installed
- Choose one authentication method:
Option 1: Personal Access Token (Easier)
Create a Personal Access Token with required scopes:
- Go to GitHub Settings > Developer Settings > Personal Access Tokens
- Click "Generate new token (classic)"
- Select scopes:
repo(Full control of private repositories)admin:org(Full control of orgs and teams) - if managing org repos
- Copy the generated token
Option 2: OAuth Device Flow (Better UX)
✨ If you're publishing this CLI tool, you can set up your own OAuth App and hardcode the Client ID - it's safe to be public!
Why Client IDs are safe to publish:
- ✅ OAuth Client IDs are designed to be public (unlike Client Secrets)
- ✅ Device Flow doesn't use secrets - security comes from user authorization
- ✅ Users explicitly approve in their browser with GitHub's authentication
- ✅ Real examples: GitHub CLI, Heroku CLI, and many others ship with hardcoded Client IDs
Setup for publishing:
- Go to GitHub Settings > Developer Settings > OAuth Apps
- Click "New OAuth App"
- Fill in the details:
- Application name: GitHub Secret Manager (or your chosen name)
- Homepage URL:
http://localhost(or your project URL) - Authorization callback URL:
http://localhost
- After creating, click "Enable Device Flow" (important!)
- Copy the Client ID
- In
cli.ts, replaceDEFAULT_OAUTH_CLIENT_IDwith your Client ID:const DEFAULT_OAUTH_CLIENT_ID = "Ov23liYourActualClientID"; - Publish! Users won't need to create their own OAuth App
For end users (if a default OAuth App is configured):
- Just run the app and choose "OAuth Device Flow"
- No need to create your own OAuth App
- Optional: Use your own OAuth App if desired
Authentication Flow
When you start the app, you'll choose between:
1. Personal Access Token
- Paste your PAT directly
- Quick and simple
- Good for personal use
2. OAuth Device Flow
- Enter your OAuth App Client ID
- Browser opens automatically to GitHub
- Enter the displayed code
- Approve the requested permissions
- Handles 2FA automatically (through GitHub's web interface)
- Can customize scopes per session
Workflow
- Login: Choose authentication method and authenticate
- Choose scope: Select Personal or Organization repositories
- Select repository: Choose which repository to manage
- Manage secrets:
- List all existing secrets
- Add/Update a single secret manually
- Upload multiple secrets from a
.envfile - Delete secrets
Example .env File
Create a .env file with your secrets:
# Database Configuration
DATABASE_URL=postgresql://user:pass@localhost:5432/db
DATABASE_PASSWORD=supersecret123
# API Keys
API_KEY=your_api_key_here
STRIPE_SECRET_KEY=sk_test_123456789
# AWS Credentials
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEYThen use the "Upload Secrets from .env File" option to batch upload all secrets to your repository.
Authentication Comparison
| Feature | Personal Access Token | OAuth Device Flow | | ------------------- | --------------------- | -------------------------------- | | Setup Complexity | Simple | Requires OAuth App | | 2FA Support | Token creation only | Handled by GitHub | | Scope Customization | During token creation | Per authentication session | | Token Visibility | You see the token | Token hidden (managed by GitHub) | | Revocation | Manual in settings | Automatic on app revoke | | Best For | Personal use, scripts | Team use, better UX |
Security Notes
- Never commit your
.envfiles to version control - Keep your GitHub token secure
- This tool runs locally and doesn't store any data
- All secrets are encrypted using libsodium before sending to GitHub
- OAuth tokens are used immediately and not stored
Troubleshooting
OAuth Device Flow Issues
- "device_flow_disabled" error: Make sure you enabled Device Flow in your OAuth App settings
- Browser doesn't open: Manually visit the URL shown in the terminal
- Token expired: The device code expires after 15 minutes. Just restart the authentication.
Permission Issues
- For organization secrets, ensure your OAuth scopes include
admin:org - For private repositories, ensure
reposcope is included
Limitations
- Secret names must only contain alphanumeric characters or underscores
- Secret names cannot start with
GITHUB_ - Secret names cannot start with a number
