{"id":18538944,"url":"https://github.com/eitrtechnologies/git-automating","last_synced_at":"2025-05-15T02:13:13.664Z","repository":{"id":239082772,"uuid":"755333944","full_name":"eitrtechnologies/git-automating","owner":"eitrtechnologies","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-09T21:34:26.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-17T08:12:54.915Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eitrtechnologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-09T22:57:37.000Z","updated_at":"2024-05-09T21:34:31.000Z","dependencies_parsed_at":"2024-05-09T22:37:57.427Z","dependency_job_id":"dc1a5954-4caf-463b-9b55-a9550a7047ed","html_url":"https://github.com/eitrtechnologies/git-automating","commit_stats":null,"previous_names":["eitrtechnologies/git-automating"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eitrtechnologies%2Fgit-automating","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eitrtechnologies%2Fgit-automating/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eitrtechnologies%2Fgit-automating/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eitrtechnologies%2Fgit-automating/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eitrtechnologies","download_url":"https://codeload.github.com/eitrtechnologies/git-automating/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259443,"owners_count":22040822,"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":[],"created_at":"2024-11-06T19:45:37.599Z","updated_at":"2025-05-15T02:13:13.638Z","avatar_url":"https://github.com/eitrtechnologies.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-automating\n\nThis script helps you manage GitLab deploy keys for projects. \n\n## Description\n\nThis script provides the ability to add or remove deploy keys for GitLab projects within a group or specific project (or list of projects). It introduces functionaility akin to a \"group level\" deploy key feature within GitLab's current framework.\n\nThe script achieves this by taking the group ID (or project ID) as input and traversing the group for projects, then applying or removing the given deploy key accordingly at the project level. Based on input, the script can look recursively through subgroups, or just apply deploy keys to a single project or list of projects directly.\n\n## Actions\n\nThe script supports two actions:\n\n* `add`: Adds a deploy key \n* `remove`: Removes a deploy key \n\n## Usage\n\n### Adding a Deploy Key\n\n**Required Parameters:**\n\n* `deploy-key` (`-d`): The public key of the deploy key to add.\n* `gitlab-token` (`-t`):  Your GitLab access token (for authentication with Gitlab API). You can also use the `GITLAB_TOKEN` environment variable.\n* `group-id` (`-i`) or `project-id` (`-p`):  The GitLab group ID or project ID (multiple project IDs can be passed).\n\n**Optional Parameters:**\n\n* `export` (`-e`): Prints the response from the GitLab API, project name, and script action to the console for each deploy key.\n* `expires-at` (`-x`): Expiration date of the deploy key to add, defaults to None, (Expected in ISO 8601 format (2019-03-15T08:00:00Z)'\n* `deploy-key-name` (`-n`): The name of the deploy key to add (defaults to `Key-YYYY-MM-DD`).\n* `can-push` (`-c`):  Set deploy key write permissions (defaults to `true`).\n* `gitlab-url` (`-g`):  Set the GitLab API URL (defaults to `https://gitlab.com/api/v4`).\n* `gitlab-headers` (`-H`):  Set GitLab API headers (defaults to `{\"PRIVATE-TOKEN\": \u003cgitlab_token\u003e}`).\n* `recursive` (`-r`): Include subgroups within a group.\n\n\n**Example Add**\n\n```\npython git-deploy-key.py add -er -n test -t \u003cgitlab-auth-token\u003e -d \"ssh-rsa AAAA...\" -i 12345\n```\n\n**Example Add with Multiple Project IDs**\n\n```\npython git-deploy-key.py add -er -n test -t \u003cgitlab-auth-token\u003e -d \"ssh-rsa AAAA...\" -p 45678 87542\n```\n\n### Using Environment Vars\n---\nTo use environment variables, export your GitLab authentication token and/or the GitLab deploy key that you want to add or remove from your projects:\n\n```\nexport GITLAB_TOKEN=\"super-secret-gitlab-auth-key\"\nexport GITLAB_DEPLOY_KEY=\"ssh-rsa AAAA...\"\n```\n\n**Example Running Script with Environment Vars**\n\n```\npython git-deploy-key.py add -er -n test -i 12345\n```\n---\n\n### Removing a deploy key\n\n* `deploy-key-name` (`-n`) or `deploy-key` (`-n`): The name of the deploy key or the ssh key value to remove. Note: if using ssh key value you must include the (`-D`) flag, otherwise it will only remove by deploy key name.\n* `gitlab-token` (`-t`):  Your GitLab access token (for authentication with Gitlab API). You can also use the `GITLAB_TOKEN` environment variable.\n* `group-id` (`-i`) or `project-id` (`-p`):  The GitLab group ID or project ID (multiple project IDs can be passed).\n\n**Optional Parameters:**\n\n* `export` (`-e`): Prints the response from the GitLab API, project name, and script action to the console for each deploy key.\n* `can-push` (`-c`):  Set deploy key write permissions (defaults to `true`).\n* `gitlab-url` (`-g`):  Set the GitLab API URL (defaults to `https://gitlab.com/api/v4`).\n* `gitlab-headers` (`-H`):  Set GitLab API headers (defaults to `{\"PRIVATE-TOKEN\": \u003cgitlab_token\u003e}`).\n* `recursive` (`-r`): Include subgroups within a group.\n* `remove-by-key` (`-D`): remove deploy key based off of ssh key value (defaults to `true`)\n\n**Example Remove by Deploy Key Name Only**\n\n```\npython git-deploy-key.py remove -er -n test -t \u003cgitlab-auth-token\u003e -i 12345\n```\n\n**Example Remove by Deploy Key Value**\n\n```\npython git-deploy-key.py remove -Dd \"ssh-rsa AAAA...\" -t \u003cgitlab-auth-token\u003e -i 12345 \n```\n\n## All Options\n\n| Option (Short Flag) | Long Flag | Description | Default Value |\n|---|---|---|---|\n| -n | --deploy-key-name | GitLab deploy key name. | Key-YYYY-MM-DD |\n| -d | --deploy-key | GitLab deploy key ID. | GITLAB_DEPLOY_KEY environment variable or None |\n| -t | --gitlab-token | GitLab access token. | GITLAB_TOKEN environment variable or None |\n| -i | --group-id | GitLab group ID. | - |\n| -p | --project-id | GitLab project ID. | - |\n| -g | --gitlab-url | GitLab API URL. | [https://gitlab.com/api/v4](https://gitlab.com/api/v4) |\n| -H | --gitlab-headers | GitLab API headers. | {\"PRIVATE-TOKEN\": \u003cgitlab_token\u003e} |\n| -c | --can-push | Deploy key write permissions. | true |\n| -e | --export | Print response from GitLab API, project name, and script action. | - |\n| -r | --recursive | Include subgroups within a group. | - |\n| -x | --expires-at | Deploy key expiration date | None |\n| -D | --remove-by-key | remove deploy key based off of ssh key value (defaults to `true`) | true |\n\n## Note:\n\n- Tested on https://gitlab.com/api/v4 version\n- If --export (-e) is not included as an arg when executing the script, a successful run will not print anything to the console. However, if an error is hit during executing a log message will still print.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feitrtechnologies%2Fgit-automating","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feitrtechnologies%2Fgit-automating","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feitrtechnologies%2Fgit-automating/lists"}