{"id":20364464,"url":"https://github.com/justwriteclick/gh-webhooks","last_synced_at":"2025-10-10T16:44:38.598Z","repository":{"id":73642107,"uuid":"273048184","full_name":"justwriteclick/gh-webhooks","owner":"justwriteclick","description":"List and create GitHub webhooks on repositories","archived":false,"fork":false,"pushed_at":"2020-09-25T17:24:03.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-04T18:46:07.645Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justwriteclick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-06-17T18:18:09.000Z","updated_at":"2021-06-16T10:42:29.000Z","dependencies_parsed_at":"2023-04-08T15:23:23.570Z","dependency_job_id":null,"html_url":"https://github.com/justwriteclick/gh-webhooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/justwriteclick/gh-webhooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justwriteclick%2Fgh-webhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justwriteclick%2Fgh-webhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justwriteclick%2Fgh-webhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justwriteclick%2Fgh-webhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justwriteclick","download_url":"https://codeload.github.com/justwriteclick/gh-webhooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justwriteclick%2Fgh-webhooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004705,"owners_count":26083751,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-15T00:12:04.373Z","updated_at":"2025-10-10T16:44:38.569Z","avatar_url":"https://github.com/justwriteclick.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create webhooks with GitHub API\n\nThis code example takes in a file with a list of GitHub repositories and uses a `config.py` file containing the required credentials, org, and so on, to either list or create webhooks in each repo.\n\nTo use these scripts, clone this repository locally. These scripts have been tested with Python 3.8.\n\n## Credentials\n\nYou'll need to create a personal access token using the instructions at https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token. Treat this token as you would a password and only give it the minimum permissions needed for the automation tasks.\n* To run against an org, you must have the `admin:org` scope for the token.\n\n## Config file\n```\ngh_username = \"username\"\ngh_api_key = \"9d1f1dcf---c58b5032a\" # Create from Settings \u003e Profile \u003e Developer settings \u003e Personal access token, scope should be admin:repo_hook\ngh_orgname = \"organizationname\"\ngh_secret = \"d954a2----dde787\" # This value is inserted in the payload for creating a webhook that requires a secret\n```\n\n## File containing list of repositories\n\nCreate a text file with one repo name per line, and be sure not to add an extra new line at the end of the file. If you have an extra new line, the script will return with \"Not Found\" for the last \"repo name\" in the file.\n\nIn this repository example, we have a Python script that can read in a JSON file and output a list of repository names by extracting the data from the JSON file. The JSON file is made from an internal-to-Cisco API endpoint used for publishing to https://developer.cisco.com/learning/.\n\n## Webhook Payload\nIn this example, the payload is modeled after the GitHub v3 REST API documentation for webhooks at: https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook.\n\nIn this case, the webhook URL is an internal-to-Cisco webhook URL made available for this use case. You would substitute in the URL for your webhook.\n\nThis webhook also requires a secret, so that secret is stored in a `config.py` file when you run the script. That `config.py` file is in the `.gitignore` file so that this public repo will not reveal the secret. \n```\n{\n               'name': 'web',\n               'active': True,\n               'events': ['release'],\n               'config': {\n                           'url': 'https://devnet-int-svcs.cisco.com/api/githubs/githubWebhook/release',\n                           'content_type': 'json',\n                           'secret': '{}'.format(gh_secret),\n                           'insecure_ssl': '0'\n                           }\n               }\n```\n\nMore details about the possible events you can trigger the webhook on, what the other `config` settings mean, can be found in these documents: https://developer.github.com/webhooks/event-payloads/. \n\n## Usage\n\nOnce you have your config file and a list of repositories in a text file, you can run the script like so:\n\n```\npython create_webhook.py repolist.txt\n```\n\n## Contributing\n\nContributions are welcome, refer to the  [CONTRIBUTING](./CONTRIBUTING.md) file for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustwriteclick%2Fgh-webhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustwriteclick%2Fgh-webhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustwriteclick%2Fgh-webhooks/lists"}