gh-migrate-rulesets

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 2 Imported by: 0

README

gh-migrate-rulesets

A GitHub gh CLI extension to create a report containing repository rulesets for a single repository, list of repositories, and/or organization, as well as create repository rulesets from a file.

Installation

  1. Install the gh CLI - see the installation instructions.

  2. Install the extension:

    gh extension install katiem0/gh-migrate-rulesets
    

For more information: gh extension install.

Usage

The gh-migrate-rulesets extension supports GitHub.com and GitHub Enterprise Server, through the use of --hostname and the following commands:

$ gh migrate-rulesets -h
List and create repository/organization level rulesets for repositories in an organization.

Usage:
  migrate-rules [command]

Available Commands:
  create      Create repository rulesets
  list        Generate a report of rulesets for repositories and/or organization.

Flags:
  -h, --help   help for migrate-rules

Use "migrate-rules [command] --help" for more information about a command.
List Repository Rulesets

The gh migrate-rulesets list command will create a csv report of repository rulesets for the specified <organization> and/or [repo ..] list, with the ability to specify the --host-name and --token associated to a Server instance. If only <organization> is provided, all repositories will be used.

To specify the type of ruleset to list, setting the --ruleType flag will either list:

  • all: Organization level, and repository level rulesets
  • repoOnly: Repository level rulesets for list of repos or all repos under <organization>
  • orgOnly: Organization level rulesets only
$ gh migrate-rulesets list -h
Generate a report of rulesets for a list of repositories and/or organization.

Usage:
  migrate-rules list [flags] <organization> [repo ...]

Flags:
  -d, --debug                To debug logging
  -h, --help                 help for list
      --hostname string      GitHub Enterprise Server hostname (default "github.com")
  -o, --output-file string   Name of file to write CSV list to (default "ruleset-20240819094546.csv")
  -r, --ruleType string      List rulesets for a specific application or all: {all|repoOnly|orgOnly} (default "all")
  -t, --token string         GitHub Personal Access Token (default "gh auth token")

The output csv file contains the following information:

Click to Expand output csv file contents
Field NameDescription
RulesetLevelIndicates whether the ruleset is at the organization or repository level.
RepositoryNameIf repository level ruleset, the name of the repository where the data is extracted from. For Organization rulesets, this is `N/A`.
RuleIDUnique identifier for the rule.
RulesetNameName of the ruleset.
TargetIndicates the type of ruleset, can be `branch`, `tag`, or `push`.
EnforcementEnforcement level of the ruleset (e.g., `active`, `evaluate`, or `disabled`).
BypassActorsActors who can bypass the ruleset, specified in the format `ID;Role;Condition`.
ConditionsRefNameIncludeArray of `ref` names to include in the ruleset conditions.
ConditionsRefNameExcludeArray of `ref` names to exclude from the ruleset conditions.
ConditionsRepoNameIncludeArray of repository names to include in the ruleset conditions.
ConditionsRepoNameExcludeArray of repository names to exclude from the ruleset conditions.
ConditionsRepoNameProtectedIndicates whether renaming of target repositories is prevented.
ConditionRepoPropertyIncludeArray of repository properties values to include in the ruleset conditions.
ConditionRepoPropertyExcludeArray of repository properties values to exclude from the ruleset conditions.
RulesCreationOnly allow users with bypass permission to create matching refs.
RulesUpdateOnly allow users with bypass permissions to delete matching refs.
RulesDeletionPrevent merge commits from being pushed to matching refs.
RulesRequiredLinearHistoryPrevent merge commits from being pushed to matching refs.
RulesMergeQueueMerges must be performed via a merge queue. In the format `check_response_timeout_minutes|grouping_strategy|max_entries_to_build|max_entries_to_merge|merge_method|min_entries_to_merge|min_entries_to_merge_wait_minutes`
RulesRequiredDeploymentsChoose which environments must be successfully deployed to before refs can be pushed into a ref that matches this rule. Includes `required_deployment_environments` array.
RulesRequiredSignaturesCommits pushed to matching refs must have verified signatures.
RulesPullRequestRequire all commits be made to a non-target branch and submitted via a pull request before they can be merged. In the format `dismiss_stale_reviews_on_push|require_code_owner_review|require_last_push_approval|required_approving_review_count|required_review_thread_resolution`
RulesRequiredStatusChecksChoose which status checks must pass before the ref is updated. An array of required status check rules, in the format `do_not_enforce_on_create|required_status_checks:{context|integration}|strict_required_status_checks_policy`
RulesNonFastForwardPrevent users with push access from force pushing to refs.
RulesCommitMessagePatternIndicates commit message patterns and matching. In the format `Name|Negate|Operator|Pattern`
RulesCommitAuthorEmailPatternIndicates commit author email patterns and matching. In the format `Name|Negate|Operator|Pattern`
RulesCommitterEmailPatternIndicates committer email patterns and matching. In the format `Name|Negate|Operator|Pattern`
RulesBranchNamePatternIndicates branch name patterns and matching. In the format `Name|Negate|Operator|Pattern`
RulesTagNamePatternIndicates tag name patterns and matching. In the format `Name|Negate|Operator|Pattern`
RulesFilePathRestrictionPrevent commits that include changes in specified file paths from being pushed to the commit graph.
RulesFilePathLengthPrevent commits that include file paths that exceed a specified character limit from being pushed to the commit graph.
RulesFileExtensionRestrictionRestrictions on file extensions for the ruleset.
RulesMaxFileSizeMaximum file size allowed to be pushed to the commit.
RulesWorkflowsRequire all changes made to a targeted branch to pass the specified workflows before they can be merged. An array of workflow rules, in the format `do_not_enforce_on_create|workflows:{Path|ref|repository_id|sha}`
RulesCodeScanningChoose which tools must provide code scanning results before the reference is updated. An array of code scanning rules in the format `{Tool|SecurityAlertsThreshold|AlertsThreshold}`
CreatedAtTimestamp of when the ruleset was created.
UpdatedAtTimestamp of when the ruleset was last updated.
Create Repository Rulesets

Repository Rulesets can be created from a csv file using --from-file following the format outlined in gh-migrate-rulesets list.

[!NOTE] Be sure to update the repository_id in RulesWorkflows field for required workflows for the correct repository under the new Organization else the addition of this ruleset will fail.

$ gh migrate-rulesets create -h                                                   
Create repository rulesets at the repo and/or org level from a file.

Usage:
  migrate-rules create [flags] <organization>

Flags:
  -d, --debug              To debug logging
  -f, --from-file string   Path and Name of CSV file to create repository rulesets from
  -h, --help               help for create
      --hostname string    GitHub Enterprise Server hostname (default "github.com")
  -t, --token string       GitHub personal access token for organization to write to (default "gh auth token")

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
internal
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL