{"id":27201045,"url":"https://github.com/katiem0/gh-environments","last_synced_at":"2025-04-09T21:46:21.586Z","repository":{"id":164520303,"uuid":"639914915","full_name":"katiem0/gh-environments","owner":"katiem0","description":"GitHub CLI extension to list and create environment metadata, including secrets and variables.","archived":false,"fork":false,"pushed_at":"2024-12-20T18:28:12.000Z","size":69,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-20T19:32:36.275Z","etag":null,"topics":["environments","gh-extension","go","golang","secrets","variables"],"latest_commit_sha":null,"homepage":"","language":"Go","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/katiem0.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":"2023-05-12T14:11:29.000Z","updated_at":"2024-12-20T18:24:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"17eecbbe-5fed-4fc9-a51b-fd9f4ea307f5","html_url":"https://github.com/katiem0/gh-environments","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katiem0%2Fgh-environments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katiem0%2Fgh-environments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katiem0%2Fgh-environments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katiem0%2Fgh-environments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katiem0","download_url":"https://codeload.github.com/katiem0/gh-environments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119439,"owners_count":21050754,"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":["environments","gh-extension","go","golang","secrets","variables"],"created_at":"2025-04-09T21:46:21.122Z","updated_at":"2025-04-09T21:46:21.575Z","avatar_url":"https://github.com/katiem0.png","language":"Go","funding_links":[],"categories":["🧩 Categories"],"sub_categories":["Search \u0026 Discovery"],"readme":"# gh-environments\n\nA GitHub `gh` [CLI](https://cli.github.com/) extension to list environments and their associated metadata for an organization and/or specific repositories. \n\n## Installation\n\n1. Install the `gh` CLI - see the [installation](https://github.com/cli/cli#installation) instructions.\n\n2. Install the extension:\n   ```sh\n   gh extension install katiem0/gh-environments\n   ```\n\nFor more information: [`gh extension install`](https://cli.github.com/manual/gh_extension_install).\n\n## Usage\n\nThe `gh-environments` extension supports `GitHub.com` and GitHub Enterprise Server, through the use of `--hostname` and the following commands:\n\n```sh\n$ gh environments -h\n\nList and create repo environments and metadata, including listing and creating environment secrets and variables.\n\nUsage:\n  environments [command]\n\nAvailable Commands:\n  create      Create environments and metadata.\n  list        Generate a report of environments and metadata.\n  secrets     List and Create Environment secrets.\n  variables   List and Create Environment variables.\n\nFlags:\n      --help   Show help for command\n\nUse \"environments [command] --help\" for more information about a command.\n```\n\n### List Environments\n\nEnvironment metadata can be listed and written to a `csv` file for an organization or specific repository.\n\n\n```sh\n$ gh environments list -h\n\nGenerate a report of environments and metadata for a single repository or all repositories in an organization.\n\nUsage:\n  environments list [flags] \u003corganization\u003e [repo ...] \n\nFlags:\n  -d, --debug                To debug logging\n      --hostname string      GitHub Enterprise Server hostname (default \"github.com\")\n  -o, --output-file string   Name of file to write CSV report (default \"report-20230512095310.csv\")\n  -t, --token string         GitHub Personal Access Token (default \"gh auth token\")\n\nGlobal Flags:\n      --help   Show help for command\n```\n\n#### Report Output\n\nThe output `csv` file contains the following information:\n\n| Field Name | Description |\n|:-----------|:------------|\n|`RepositoryName` | The name of the repository where the data is extracted from. |\n|`RepositoryID`| The `ID` associated with the Repository, for API usage. |\n|`EnvironmentName`| The name of the repository specific environment. |\n|`AdminBypass`| `True`/`False` flag to indicate if administrators are allowed to bypass configured protection rules. |\n|`WaitTimer`| The an amount of time to wait before allowing deployments to proceed. |\n|`Reviewers`| Specified people or teams that have the ability to approve workflow runs when they access the environment. In the format `\u003cUserOrTeam\u003e;Name;ID` and reviewers delimited by `|` |\n|`PreventSelfReview` | Indicates if a Reviewer is able to approve/deny the workflow run on a specific environment |\n|`BranchPolicyType`| Indicates if the environment can only be deployed to specific branches. (Values: `protected`, `custom`, or `null`, where `null` indicates **any branch from the repo can deploy**.)|\n|`Branches`| If `BranchPolicyType = custom`, list of specific branch name patterns the environment deployment is limited to. In the format `Name;\u003cBranchOrTag\u003e` and policies delimited by `|`|\n|`CustomDeploymentProtectionPolicy`| Lists the custom deployment protection rules that are enabled for an environment. In the format: `PolicyID;Enabled;AppID;AppSlug` and policies delimited by `|`|\n|`SecretsTotalCount`| The number of Actions secrets that are associated with the environment. |\n|`VariablesTotalCount`| The number of Actions variables that are associated with the environment. |\n\n### Create Environments\n\nThe `gh environments create` command will create environments from a `csv` file using `--from-file` following the format outlined in [`gh environments create`](#environment-create).\n\n```sh\n$ gh environments create -h\n\nCreate environments and metadata for specified environments per repository in an organization from a file.\n\nUsage:\n  environments create  \u003ctarget organization\u003e [flags]\n\nFlags:\n  -d, --debug              To debug logging\n  -f, --from-file string   Path and Name of CSV file to create environments from\n      --hostname string    GitHub Enterprise Server hostname (default \"github.com\")\n  -t, --token string       GitHub personal access token for organization to write to (default \"gh auth token\")\n\nGlobal Flags:\n      --help   Show help for command\n```\n\nThe `create` command utilizes the following fields in their given format but expects all headers listed [Report Output](#report-output): \n\n| Field Name | Description |\n|:-----------|:------------|\n|`RepositoryName` | The name of the repository where the data is extracted from. |\n|`EnvironmentName`| The name of the repository specific environment. |\n|`AdminBypass`| `True`/`False` flag to indicate if administrators are allowed to bypass configured protection rules. |\n|`WaitTimer`| The an amount of time to wait before allowing deployments to proceed. |\n|`Reviewers`| Specified people or teams that have the ability to approve workflow runs when they access the environment. In the format `\u003cUserOrTeam\u003e;Name;ID` and reviewers delimited by `|` |\n|`PreventSelfReview` | Indicates if a Reviewer is able to approve/deny the workflow run on a specific environment |\n|`BranchPolicyType`| Indicates if the environment can only be deployed to specific branches. (Values: `protected`, `custom`, or `null`, where `null` indicates **any branch from the repo can deploy**.)|\n|`Branches`| If `BranchPolicyType = custom`, list of specific branch name patterns the environment deployment is limited to. In the format `Name;\u003cBranchOrTag\u003e` and policies delimited by `|`|\n\n### Environment Secrets\n\nThe `gh environment secrets` command comprises of two subcommands, `list` and `create`, to access and create Environment specific Secrets.\n\n```sh\n$ gh environments secrets -h\n\nList and Create Environment specific secrets in repositories.\n\nUsage:\n  environments secrets [command]\n\nAvailable Commands:\n  create      Create Environment secrets.\n  list        Generate a report of Environment secrets.\n\nFlags:\n      --help   Show help for command\n\nUse \"environments secrets [command] --help\" for more information about a command.\n```\n\nBoth the `create` and `list` commands utilize the following fields: \n\n| Field Name | Description |\n|:-----------|:------------|\n|`RepositoryID`| The `ID` associated with the Repository, for API usage. |\n|`RepositoryName` | The name of the repository where the data is extracted from. |\n|`EnvironmentName`| The name of the repository specific environment. |\n|`SecretName`| The name of the secret|\n|`SecretValue`| Will be blank for `list`, and is required for `create` |\n|`SecretCreatedAt`| The timestamp associated with when the secret was initially created. |\n|`SecretUpdatedAt`| The timestamp associated with the last time the secret was modified. |\n\n#### Create Secrets\n\nThe `gh environments secrets create` command will create secrets from a `csv` file using `--from-file` following the format outlined in [`gh environments secrets`](#environment-secrets).\n\n\u003e**Note**\n\u003e The `SecretValue` specified in the `csv` file will be [encrypted using the associated `public key`](https://docs.github.com/en/actions/security-guides/encrypted-secrets) before the environment secret is created.\n\n```sh\n$ gh environments secrets create -h\n\nCreate Environment secrets for specified environments per repository in an organization from a file.\n\nUsage:\n  environments secrets create \u003corganization\u003e [flags]\n\nFlags:\n  -d, --debug              To debug logging\n  -f, --from-file string   Path and Name of CSV file to create secrets from\n      --hostname string    GitHub Enterprise Server hostname (default \"github.com\")\n  -t, --token string       GitHub personal access token for organization to write to (default \"gh auth token\")\n\nGlobal Flags:\n      --help   Show help for command\n```\n\n#### List Secrets\n\nThe `gh environments secrets list` command generates a `csv` report of environment specific secrets for the specified `\u003corganization\u003e` or `[repo ..]` list. If `[repo ...]` is specified, **secrets associated to environments across all repositories will be captured**. The report will contain secrets produces a `csv` report containing the fields outlined in [`gh environments secrets`](#environment-secrets).\n\n\u003e**Note**\n\u003e The `SecretValue` specified in the `csv` file will be left blank. **Secret values will NOT be extracted.**\n\n\n```sh\n$ gh environments secrets list -h\n\nGenerate a report of secrets for each environment per repository in an organization.\n\nUsage:\n  environments secrets list [flags] \u003corganization\u003e [repo ...] \n\nFlags:\n  -d, --debug                To debug logging\n      --hostname string      GitHub Enterprise Server hostname (default \"github.com\")\n  -o, --output-file string   Name of file to write CSV report (default \"report-20230512134718.csv\")\n  -t, --token string         GitHub Personal Access Token (default \"gh auth token\")\n\nGlobal Flags:\n      --help   Show help for command\n```\n\n\n### Environment Variables\n\nThe `gh environment variables` command comprises of two subcommands, `list` and `create`, to access and create Environment specific variables.\n\n```sh\n$  gh environments variables -h\n\nList and Create Environment specific variables in repositories under an organization.\n\nUsage:\n  environments variables [command]\n\nAvailable Commands:\n  create      Create Environment variables.\n  list        Generate a report of Environment variable.\n\nFlags:\n      --help   Show help for command\n\nUse \"environments variables [command] --help\" for more information about a command.\n```\n\nBoth the `create` and `list` commands utilize the following fields: \n\n| Field Name | Description |\n|:-----------|:------------|\n|`RepositoryID`| The `ID` associated with the Repository, for API usage. |\n|`RepositoryName` | The name of the repository where the data is extracted from. |\n|`EnvironmentName`| The name of the repository specific environment. |\n|`VariableName`| The name of the variable|\n|`VariableValue`| The value of the variable |\n|`VariableCreatedAt`| The timestamp associated with when the variable was initially created. |\n|`VariableUpdatedAt`| The timestamp associated with the last time the variable was modified. |\n\n#### Create Variables\n\nThe `gh environments variables create` command will create variables from a `csv` file using `--from-file` following the format outlined in [`gh environments variables`](#environment-variables).\n\n\n\n```sh\n$ gh environments variables create -h\n\nCreate Environment variables for specified environments per repository in an organization from a file.\n\nUsage:\n  environments variables create \u003corganization\u003e [flags]\n\nFlags:\n  -d, --debug              To debug logging\n  -f, --from-file string   Path and Name of CSV file to create variables from\n      --hostname string    GitHub Enterprise Server hostname (default \"github.com\")\n  -t, --token string       GitHub personal access token for organization to write to (default \"gh auth token\")\n\nGlobal Flags:\n      --help   Show help for command\n```\n\n#### List Variables\n\nThe `gh environments variables list` command generates a `csv` report of environment specific secrets for the specified `\u003corganization\u003e` or `[repo ..]` list. If `[repo ...]` is specified, **variables associated to environments across all repositories will be captured**. The report will contain variables produces a `csv` report containing the fields outlined in [`gh environments variables`](#environment-variables).\n\n\n```sh\n$ gh environments variables list -h\n\nGenerate a report of variables for each environment per repository in an organization.\n\nUsage:\n  environments variables list [flags] \u003corganization\u003e [repo ...] \n\nFlags:\n  -d, --debug                To debug logging\n      --hostname string      GitHub Enterprise Server hostname (default \"github.com\")\n  -o, --output-file string   Name of file to write CSV report (default \"report-20230512135332.csv\")\n  -t, --token string         GitHub Personal Access Token (default \"gh auth token\")\n\nGlobal Flags:\n      --help   Show help for command\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatiem0%2Fgh-environments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatiem0%2Fgh-environments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatiem0%2Fgh-environments/lists"}