GitHub Secret Updater
Background
Managing secrets in GitHub repositories is crucial for maintaining security in CI/CD pipelines. This script automates the process of updating secrets in GitHub repositories using GitHub API.
What is the Script/Package
This script allows you to update GitHub secrets either by specifying individual secret names and values or by reading from an environment file (.env). It fetches the public key for the repository, encrypts the secret using the public key, and then updates the secret in the repository.
Usage
Installation
-
Install the required Python packages:
pip install secret-updater
-
Save the script to a file, for example,
update_github_secrets.py.
Command Line Arguments
--secret: Name of the secret to update--value: Value of the secret to update--repo: Name of the repository (in the formatowner/repo)--token: GitHub token (can also be set as an environment variableGH_TOKEN)--env-file: Path to the environment file containing secrets (recommended filename:.env)
Examples
Update a Single Secret
To update a single secret:
secret-updater --secret SECRET_NAME --value SECRET_VALUE --repo owner/repo --token YOUR_GITHUB_TOKEN
To update a set of secrets from an environment file:
secret-updater --env-file .env --repo owner/repo --token YOUR_GITHUB_TOKEN
The env file should contain the secrets in the formats
SECRET_NAME=SECRET_VALUE
or
export SECRET_NAME="SECRET_VALUE"
Metadata
Release files for secret-updater 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| secret_updater-0.1.2.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| secret_updater-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / secret_updater-0.1.2.tar.gz
| Download URL | secret_updater-0.1.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
245c5d7c73d0b7e9fb184a611447ffe6d6188ab2b60a815f352939cf7f0c4589
|
|
BLAKE2b-256 checksum How to use checksums |
88402c2cfc3305f7600dcfd7dcc0c9ee8f3d2becdd095fc81a6217ec0d4e7ab4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / secret_updater-0.1.2-py3-none-any.whl
| Download URL | secret_updater-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e184bd19615405ef84ac87c53c3d9b02fbfc80af9ec47d88a5966d8e4c185b5
|
|
BLAKE2b-256 checksum How to use checksums |
812836e247d710ee02112f9f0fb5f1a5335d014f8b49141bf6097350f9218b49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|