Sync your .env files with Github Secrets
Project description
ghss
Sync your .env files with GitHub Repository Variables in both directions using a simple CLI tool.
⚠️ IMPORTANT SECURITY NOTICE
This tool uses GitHub Repository Variables, NOT GitHub Secrets.
- Variables are NOT encrypted and their values can be retrieved via the GitHub API
- Repository collaborators may have access to variable values depending on permissions
- Do NOT store sensitive secrets like API keys, passwords, or tokens using this tool
- For sensitive data, use GitHub Secrets directly or a proper secrets management solution
See GitHub's documentation on configuration variables for more information about security implications.
What it does
ghss synchronizes environment variables between your local .env files and GitHub repository variables. You can push variables from your local environment to GitHub or pull variable names and values from GitHub to create a .env file.
Typical Use Case
You start working on a new repository and create a .env file with all your configuration. Later, you move to another PC, clone your repo, and notice the .env file is missing (because it's gitignored). With ghss, you can:
- Push variables to GitHub from your first PC:
uvx --refresh ghss set - Pull variables from GitHub on your second PC:
uvx --refresh ghss get - You're ready to work with your configuration restored
This leverages GitHub Repository Variables to store your environment configuration without committing data to your repository.
Note: This is suitable for non-sensitive configuration values. For sensitive data, use proper secrets management.
Installation
No installation required! Just run the tool directly using uvx:
uvx --refresh ghss [command]
The --refresh flag ensures you're always running the latest version.
Prerequisites
ghss requires the GitHub CLI (gh) to be installed and authenticated. This is typically already set up if you work with GitHub repositories.
To check if you're authenticated:
gh auth status
If not authenticated, run:
gh auth login
Commands
testconf
Test your configuration by creating, reading, and deleting a test variable in your repository.
Usage:
uvx --refresh ghss testconf
Example output:
Testing gh CLI authentication...
✓ gh CLI is authenticated
✓ Using repository: MiguelElGallo/ghs
Creating test variable: GHS_TEST_VARIABLE_abc12345...
✓ Test variable created
Verifying test variable exists...
Waiting 3 seconds before trying to get the variable...
✓ Test variable verified
✓ Test variable value verified
Deleting test variable...
✓ Test variable deleted
✓ All tests passed! Configuration is working correctly.
Options:
--help: Show help message
get
Get all variables from the repository and write them to a .env file with their values.
Note: Unlike GitHub Secrets, variable values CAN be retrieved from the API. The values will be written to your local .env file.
⚠️ Security Warning: Variable values are retrievable and may be visible to repository collaborators.
Usage:
uvx --refresh ghss get
uvx --refresh ghss get -f custom.env
Example output:
Checking gh CLI authentication...
Getting variables from repository: MiguelElGallo/ghs
Found 3 variable(s)
Writing variables to .env...
✓ Variables written to .env
⚠️ WARNING: Variable values are retrievable via API and may be visible to repository collaborators!
See https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository for more info.
Options:
-f, --file TEXT: Output file path (default:.env)--help: Show help message
Generated file format:
API_KEY=your_api_key_value
DATABASE_URL=postgres://localhost/db
APP_ENV=development
set
Read a .env file and set the variables in the repository.
⚠️ Security Warning: All values will be stored as repository variables and may be accessible to collaborators. You will be prompted for confirmation before proceeding.
Usage:
uvx --refresh ghss set
uvx --refresh ghss set -f custom.env
Example output:
Checking gh CLI authentication...
Found 3 variable(s) to set in repository: MiguelElGallo/ghs
⚠️ WARNING: All values of your .env file will be set as variables of this repository.
Repository collaborators could have access to these values.
See https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository for more info.
Do you want to continue? [y/N]: y
Setting variables...
Setting variable: API_KEY...
Setting variable: DATABASE_URL...
Setting variable: APP_ENV...
✓ Successfully set 3 variable(s)
Options:
-f, --file TEXT: Input file path (default:.env)--help: Show help message
Input file format:
API_KEY=your_api_key_here
DATABASE_URL=postgres://user:pass@localhost/db
APP_ENV=development
Example Workflow
⚠️ Important: This tool stores values as repository variables, not secrets. Only use it for non-sensitive configuration data.
-
Initial setup on your main PC:
# Create your .env file with configuration echo "API_URL=https://api.example.com" >> .env echo "APP_ENV=development" >> .env # Test configuration uvx --refresh ghss testconf # Push variables to GitHub (you'll be prompted for confirmation) uvx --refresh ghss set
-
On a different PC:
# Clone your repository git clone https://github.com/yourusername/yourrepo.git cd yourrepo # Pull variables from GitHub (values included!) uvx --refresh ghss get # You're ready to work!
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghss-0.1.1.tar.gz.
File metadata
- Download URL: ghss-0.1.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad4f7da467c59e425f73c702bb20fcd7b3220e5daf0a6ceffb255231bd16ab0
|
|
| MD5 |
228956196ef7fe71a1c4b8d9ed230d02
|
|
| BLAKE2b-256 |
539c5397aa5a52e62acf30375f01a3663c4fc3343d77ab743e65a2f97097308d
|
File details
Details for the file ghss-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ghss-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a57af501ad684ccab6aba22602b16c93b7fe49d5eaa4de005a45dfe5ed7935
|
|
| MD5 |
879ace055a3c13e7f4718710d0c7af34
|
|
| BLAKE2b-256 |
2efd3148bc80edabf3f5df45eda39566f190e5b98ae2de78ac85895272e6d8a9
|