{"id":19889185,"url":"https://github.com/ernail/glpushrule","last_synced_at":"2025-05-02T17:33:25.015Z","repository":{"id":180526922,"uuid":"655419511","full_name":"erNail/glpushrule","owner":"erNail","description":"CLI for managing Gitlab push rules across groups and repositories. Apply sweeping changes with one command.","archived":false,"fork":false,"pushed_at":"2024-08-10T01:28:02.000Z","size":568,"stargazers_count":4,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-10T02:35:23.042Z","etag":null,"topics":["cli","gitlab"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/erNail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-06-18T20:46:03.000Z","updated_at":"2024-06-24T14:24:30.000Z","dependencies_parsed_at":"2023-10-23T19:29:11.814Z","dependency_job_id":"81d9b1fc-fb36-4170-94aa-007232ed8eb0","html_url":"https://github.com/erNail/glpushrule","commit_stats":null,"previous_names":["ernail/glpushrule","ernail/gitlab-push-rule-manager"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erNail%2Fglpushrule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erNail%2Fglpushrule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erNail%2Fglpushrule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erNail%2Fglpushrule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erNail","download_url":"https://codeload.github.com/erNail/glpushrule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224324421,"owners_count":17292521,"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":["cli","gitlab"],"created_at":"2024-11-12T18:09:22.290Z","updated_at":"2024-11-12T18:09:22.910Z","avatar_url":"https://github.com/erNail.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# glpushrule\n\nCLI for managing Gitlab push rules across groups and repositories. Apply sweeping changes with one command.\n\n**Features:**\n\n- Show push rules across groups and repositories\n- Add push rules to groups and repositories without existing push rules\n- Edit push rules for groups and repositories with existing push rules\n\n**Planned features:**\n\n- Delete push rules across groups and repositories\n\n## Usage\n\n### Install `glpushrule`\n\n```shell\n# With npm\nnpm i -g glpushrule\n\n# With yarn\nyarn global add glpushrule\n```\n\n### Create a new Gitlab Access Token\n\n`glpushrule` needs read/write access to the API so it can show and edit push rules.\nIn your Gitlab instance, create a new access token with the `api` scope.\n\n### Set the required environment variables\n\n`glpushrule` requires the Environment variables `GITLAB_HOST` and `GITLAB_TOKEN` to be set.\nYou can set them via a `.env` file, or in your shell.\n\nTo use a `.env` file, create a new file named `.env` in the directory you are executing `glpushrule`\n\n```shell\n# .env\nGITLAB_HOST=\"https://gitlab.com/\"\nGITLAB_TOKEN=\"\u003cYOUR_SECRET_TOKEN\u003e\"\n```\n\nAlternatively, you can set them in the shell as follows:\n\n```shell\n# Export them in the environment\nexport GITLAB_HOST=\"https://gitlab.com/\"\nexport GITLAB_TOKEN=\"\u003cYOUR_SECRET_TOKEN\u003e\"\n\n# Or set them during execution\nGITLAB_HOST=\"https://gitlab.com/\" GITLAB_TOKEN=\"\u003cYOUR_SECRET_TOKEN\u003e\" glpushrule --help\n```\n\n### Execute `glpushrule`\n\nShow existing push rules (Recommended to test if the correct groups and projects are matched):\n\n```shell\nglpushrule show --matcher \"/regex/to/match/your/groups/and/projects/paths\"\n```\n\nAdd push rules to groups and projects without push rules:\n\n```shell\nglpushrule add --matcher \"/regex/to/match/your/groups/and/projects/paths\" --rule '{\"commitMessageRegex\": \"^ci: .*\"}'\n```\n\nEdit push rules for groups and projects with existing push rules:\n\n```shell\nglpushrule edit --matcher \"/regex/to/match/your/groups/and/projects/paths\" --rule '{\"commitMessageRegex\": \"^ci: .*\"}'\n```\n\nYou can also set the `--matcher` and `--rule` flag as Environment variables:\n\n```shell\n# .env\nGITLAB_HOST=\"https://gitlab.com/\"\nGITLAB_TOKEN=\"\u003cYOUR_SECRET_TOKEN\u003e\"\nMATCHER=\"/regex/to/match/your/groups/and/projects/paths\"\nPUSH_RULE='{\n\"commitMessageRegex\": \"^ci: .*\"\n}'\n```\n\n### Available Push Rules\n\nIn the example above, the commit message regex is used as an example for adding and editing rules.\nThe other available push rules can be found in the [gitbeaker](https://github.com/jdalrymple/gitbeaker) project,\nin the [`CreateAndEditPushRuleOptions`][1] interface:\n\n[1]: https://github.com/orchestracities/ngsi-timeseries-api/blob/master/docs/manuals/admin/configuration.md#environment-variables\n\n```ts\nexport interface CreateAndEditPushRuleOptions {\n  denyDeleteTag?: boolean;\n  memberCheck?: boolean;\n  preventSecrets?: boolean;\n  commitMessageRegex?: string;\n  commitMessagNegativeRegex?: string;\n  branchNameRegex?: string;\n  authorEmailRegex?: string;\n  fileNameRegex?: string;\n  maxFileSize?: number;\n  commitCommitterCheck?: boolean;\n  rejectUnsignedCommits?: boolean;\n}\n```\n\n### Command documentation\n\n#### `glpushrule` command\n\n```text\n# glpushrule --help\nUsage: glpushrule [options] [command]\n\nCLI for managing Gitlab push rules across multiple groups and repositories\n\nOptions:\n  -V, --version                 output the version number\n  -m, --matcher \u003cmatcherRegEx\u003e  the regex to use for filtering groups and repositories (env: MATCHER)\n  -h, --help                    display help for command\n\nCommands:\n  edit [options]                edit already existing push rules\n  show                          show push rules\n  add [options]                 add push rules if non exist\n  help [command]                display help for command\n```\n\n#### `glpushrule add` command\n\n```text\n# glpushrule add --help\nUsage: glpushrule add [options]\n\nadd push rules if non exist\n\nOptions:\n  -r, --rule \u003cpushRuleJson\u003e     the push rules as JSON. Example: '{\"commitMessageRegex\": \"^ci: .*\"}' (env: PUSH_RULE)\n  -h, --help                    display help for command\n\nGlobal Options:\n  -V, --version                 output the version number\n  -m, --matcher \u003cmatcherRegEx\u003e  the regex to use for filtering groups and repositories (env: MATCHER)\n```\n\n#### `glpushrule edit` command\n\n```text\n# glpushrule edit --help\nUsage: glpushrule edit [options]\n\nedit already existing push rules\n\nOptions:\n  -r, --rule \u003cpushRulesJson\u003e    the push rules as JSON. Example: '{\"commitMessageRegex\": \"^ci: .*\"}' (env: PUSH_RULE)\n  -h, --help                    display help for command\n\nGlobal Options:\n  -V, --version                 output the version number\n  -m, --matcher \u003cmatcherRegEx\u003e  the regex to use for filtering groups and repositories (env: MATCHER)\n```\n\n#### Environment Variables\n\nThe application uses the following environment variables:\n\n| Environment Variable | Description                                            | Required            |\n|----------------------|--------------------------------------------------------|---------------------|\n| `GITLAB_HOST`        | The Gitlab instance in which to manage push rules      | Yes                 |\n| `GITLAB_TOKEN`       | The Gitlab Access Token with the `api` permission      | Yes                 |\n| `MATCHER`            | The regex to use for filtering groups and repositories | No, if set via flag |\n| `PUSH_RULE`          | The push rules as JSON                                 | No, if set via flag |\n\n## Development\n\n### Running\n\n```shell\nyarn install\n\n# Run with node\nyarn run start\n\n# Run with ts-node\nyarn run start:dev\n```\n\n### Linting\n\n```shell\n# Run ESLint without auto fixing\nyarn run lint\n\n# Run ESLint with auto fixing\nyarn run lint:fix\nyarn run lint --fix\n\n# Run pre-commit\npip install -r requirements.txt\nyarn run pre-commit\n```\n\n### Testing\n\n```shell\nyarn run jest\n```\n\n## Contributing\n\nPlease check out the [CONTRIBUTING.md](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fernail%2Fglpushrule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fernail%2Fglpushrule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fernail%2Fglpushrule/lists"}