{"id":20463217,"url":"https://github.com/devwithkrishna/programatically-create-delete-update-github-repository-secrets","last_synced_at":"2025-06-24T22:32:45.312Z","repository":{"id":228974296,"uuid":"775111814","full_name":"devwithkrishna/programatically-create-delete-update-github-repository-secrets","owner":"devwithkrishna","description":"programatically-create-delete-update-github-erpository-secrets","archived":false,"fork":false,"pushed_at":"2025-02-04T15:33:32.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-05T11:53:03.687Z","etag":null,"topics":["automation","github","github-action","github-rest-api","python"],"latest_commit_sha":null,"homepage":"https://github.com/devwithkrishna/programatically-create-delete-update-github-erpository-secrets","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devwithkrishna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-20T19:29:37.000Z","updated_at":"2025-02-04T15:33:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9e83d0a-0929-40fc-b01a-277901212b56","html_url":"https://github.com/devwithkrishna/programatically-create-delete-update-github-repository-secrets","commit_stats":null,"previous_names":["devwithkrishna/programatically-create-delete-update-github-repository-secrets"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devwithkrishna/programatically-create-delete-update-github-repository-secrets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devwithkrishna","download_url":"https://codeload.github.com/devwithkrishna/programatically-create-delete-update-github-repository-secrets/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261766980,"owners_count":23206724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","github","github-action","github-rest-api","python"],"created_at":"2024-11-15T13:09:55.442Z","updated_at":"2025-06-24T22:32:45.269Z","avatar_url":"https://github.com/devwithkrishna.png","language":"Python","readme":"# programatically-create-delete-update-github-repository-secrets\nprogramatically-create-delete-update-github-repository-secrets\n\n# Pre requesites\n* Personal Access Token (PAT) is the recommended way to authenticate. In this demo PAT is USED.\n* You can generate a new one from Github settings\n* You need to encrypt a secret before you can create or update secrets.\n\n\n# How code works for create or update a repository secret\n\n* First this will execute the `get_repository_public_key.py` `python program` to get the Organization public key and public key id\n    *  This public key is required and used for encryption of secret\n    * This public key id is required at time of creation or updation of secret\n\n    `Reference`: [get-a-repository-public-key](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-a-repository-public-key)\n\n\n* Then the `python program` `encrypt_using_libnacl` this uses the public key from step 1 and encrypts the secret \nusing the prefered method by GitHub.\n\n    `Reference`: [create-or-update-a-repository-secret](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret)\n\n    - Reference used for encryption : [example-encrypting-a-secret-using-python](https://docs.github.com/en/rest/guides/encrypting-secrets-for-the-rest-api?apiVersion=2022-11-28#example-encrypting-a-secret-using-python )\n\n* Then `Python program` `create_or_update_repo_secret` is used to take the public key id from above step and encrypted secret value to create or update the secret.\n\n| status code | operation                |\n|-------------|--------------------------|\n| 201  | Response when creating a repository secret |\n| 204  | Response when updating a secret repository secret   |\n\n\n\n## Inputs of workflow\n\n| input name | description|\n|------------|------------|\n| organization | name of github organization |\n| repository_name | name of github repo where secret need to be created |\n| secret_name | organization Secret name |\n| secret_value | Secret value |\n\n\n# # How code works for deleting an repository secret\n\n* This runs the `python program` `delete_repo_secret.py` which takes 3 inputs from github workflow \n1. organization name\n2. repository name \n3. secret name\n\n* Then deletes the secret\n\n| input | description| \n|-------|--------------|\n| organization | GitHub Organization name |\n| repository_name | name of github repo where secret need to be created |\n| secret_name | Secert to be deleted |","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwithkrishna%2Fprogramatically-create-delete-update-github-repository-secrets/lists"}