-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rulesets): initial support repository rulesets (semi-dark releas…
…e with the potential for breaking changes) (#1029)
- Loading branch information
Showing
9 changed files
with
327 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Repository Rulesets | ||
|
||
> [!WARNING] | ||
> Support for Repository Rulesets is still under development. | ||
> Details may still change, like how the configuration is defined in the `settings.yml`. | ||
> Please follow [#732](https://github.com/repository-settings/app/issues/732) for progress updates. | ||
> Feedback is appreciated, but adopt cautiously, with the expectation of breaking changes until support is fully released. | ||
See https://docs.github.com/en/rest/repos/rules#update-a-repository-ruleset for | ||
all available ruleset properties and a description of each. | ||
|
||
```yaml | ||
rulesets: | ||
- name: prevent destruction of the default branch | ||
target: branch | ||
enforcement: active | ||
conditions: | ||
ref_name: | ||
include: | ||
- "~DEFAULT_BRANCH" | ||
rules: | ||
- type: deletion | ||
- type: non_fast_forward | ||
|
||
- name: verification must pass | ||
target: branch | ||
enforcement: active | ||
conditions: | ||
ref_name: | ||
include: | ||
- "~DEFAULT_BRANCH" | ||
rules: | ||
- type: required_status_checks | ||
parameters: | ||
required_status_checks: | ||
- context: test | ||
integration_id: 123456 | ||
bypass_actors: | ||
- actor_id: 5 | ||
actor_type: RepositoryRole | ||
bypass_mode: pull_request | ||
|
||
- name: changes must be reviewed | ||
target: branch | ||
enforcement: active | ||
conditions: | ||
ref_name: | ||
include: | ||
- "~DEFAULT_BRANCH" | ||
rules: | ||
- type: pull_request | ||
parameters: | ||
required_approving_review_count: 1 | ||
require_code_owner_review: true | ||
bypass_actors: | ||
- actor_id: 654321 | ||
actor_type: Integration | ||
bypass_mode: always | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import deepEqual from 'deep-equal' | ||
|
||
import Diffable from './diffable.js' | ||
|
||
export default class Rulesets extends Diffable { | ||
async find () { | ||
const { data: rulesets } = await this.github.repos.getRepoRulesets(this.repo) | ||
|
||
return rulesets | ||
} | ||
|
||
comparator (existing, attrs) { | ||
return existing.name === attrs.name | ||
} | ||
|
||
changed (existing, attrs) { | ||
return !deepEqual(existing, attrs) | ||
} | ||
|
||
update (existing, attrs) { | ||
return this.github.repos.updateRepoRuleset({ ...this.repo, ruleset_id: existing.ruleset_id, ...attrs }) | ||
} | ||
|
||
remove (existing) { | ||
return this.github.repos.deleteRepoRuleset({ ...this.repo, ruleset_id: existing.ruleset_id }) | ||
} | ||
|
||
async add (attrs) { | ||
await this.github.repos.createRepoRuleset({ ...this.repo, ...attrs }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.