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.2.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.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file secret_updater-0.1.2.tar.gz.

File metadata

  • Download URL: secret_updater-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 245c5d7c73d0b7e9fb184a611447ffe6d6188ab2b60a815f352939cf7f0c4589
MD5 c8123a5499b5e82fd8d280bfb88c42c2
BLAKE2b-256 88402c2cfc3305f7600dcfd7dcc0c9ee8f3d2becdd095fc81a6217ec0d4e7ab4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: secret_updater-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e184bd19615405ef84ac87c53c3d9b02fbfc80af9ec47d88a5966d8e4c185b5
MD5 ad3fcd682c4d8dfc92d3d61fccf7b632
BLAKE2b-256 812836e247d710ee02112f9f0fb5f1a5335d014f8b49141bf6097350f9218b49

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