Skip to main content

CLI tool to update GitHub repository secrets.

Project description

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

  1. Install the required Python packages:

    pip install secret-updater
    
  2. 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 format owner/repo)
  • --token: GitHub token (can also be set as an environment variable GH_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"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secret-updater-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secret_updater-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file secret-updater-0.1.1.tar.gz.

File metadata

  • Download URL: secret-updater-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for secret-updater-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e2a7ce4e2795ca3b95a3f32d22dfc9e92ffe09e75c0ee82aa827396b6e53eec7
MD5 49a8ec54fe8d2499e277a2f989bc8ede
BLAKE2b-256 e8fc0c8670b681bfad224a76fe5d8ae5892703a2fc30f44d66fa8b581917fd36

See more details on using hashes here.

File details

Details for the file secret_updater-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: secret_updater-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for secret_updater-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab1894fd5eea7cb1dcd046f67794d8eed845040b5c9466456d35e82354ea984d
MD5 8dba308112600de83b98ee676f16ff4c
BLAKE2b-256 c38181b8fee11c6c527b369c2208941f66c3741958eae8059f732ca07c00c715

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page