-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8961f2
commit e90ae59
Showing
4 changed files
with
162 additions
and
0 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,46 @@ | ||
{ | ||
"name": "Silverstripe branch ruleset", | ||
"target": "branch", | ||
"enforcement": "active", | ||
"conditions": { | ||
"ref_name": { | ||
"exclude": [], | ||
"include": [ | ||
"refs/heads/main", | ||
"refs/heads/master", | ||
"refs/heads/[0-9]*" | ||
] | ||
} | ||
}, | ||
"rules": [ | ||
{ | ||
"type": "deletion" | ||
}, | ||
{ | ||
"type": "non_fast_forward" | ||
}, | ||
{ | ||
"type": "creation" | ||
}, | ||
{ | ||
"type": "update" | ||
}, | ||
{ | ||
"type": "pull_request", | ||
"parameters": { | ||
"required_approving_review_count": 2, | ||
"dismiss_stale_reviews_on_push": true, | ||
"require_code_owner_review": false, | ||
"require_last_push_approval": true, | ||
"required_review_thread_resolution": false | ||
} | ||
} | ||
], | ||
"bypass_actors": [ | ||
{ | ||
"actor_id": 5, | ||
"actor_type": "RepositoryRole", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "Silverstripe tag ruleset", | ||
"target": "tag", | ||
"enforcement": "active", | ||
"conditions": { | ||
"ref_name": { | ||
"exclude": [], | ||
"include": [ | ||
"~ALL" | ||
] | ||
} | ||
}, | ||
"rules": [ | ||
{ | ||
"type": "deletion" | ||
}, | ||
{ | ||
"type": "non_fast_forward" | ||
}, | ||
{ | ||
"type": "creation" | ||
}, | ||
{ | ||
"type": "update" | ||
} | ||
], | ||
"bypass_actors": [ | ||
{ | ||
"actor_id": 5, | ||
"actor_type": "RepositoryRole", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
use SilverStripe\SupportedModules\MetaData; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
$rulesetsCommand = function(InputInterface $input, OutputInterface $output): int { | ||
// This is the code that is executed when running the 'rulesets' command | ||
|
||
// variables | ||
global $OUT, $REPOS_WITH_RULESETS_UPDATED; | ||
$OUT = $output; | ||
|
||
// validate system is ready | ||
validate_system(); | ||
|
||
// setup directories | ||
setup_directories($input, [DATA_DIR]); | ||
|
||
// modules | ||
$modules = []; | ||
$repos = []; | ||
$modulesCurrentMajor = filtered_modules(MetaData::HIGHEST_STABLE_CMS_MAJOR, $input); | ||
$modulesPreviousMajor = filtered_modules(MetaData::HIGHEST_STABLE_CMS_MAJOR - 1, $input); | ||
foreach ([$modulesCurrentMajor, $modulesPreviousMajor] as $modulesList) { | ||
foreach ($modulesList as $module) { | ||
$repo = $module['repo']; | ||
$ghrepo = $module['ghrepo']; | ||
if (in_array($repo, $repos) || in_array($ghrepo, LABELS_EXCLUDE_GHREPOS)) { | ||
continue; | ||
} | ||
// Important! Only include modules on the "silverstripe" account | ||
if (!preg_match('#^silverstripe/#', $repo)) { | ||
continue; | ||
} | ||
$modules[] = $module; | ||
$repos[] = $repo; | ||
} | ||
} | ||
|
||
// sboyd | ||
$modules = [ | ||
['account' => 'emteknetnz', 'repo' => 'test-thing'], | ||
// ['account' => 'emteknetnz', 'repo' => 'tmp-docblock-annotator'], | ||
]; | ||
|
||
// update rulesets | ||
foreach ($modules as $module) { | ||
$account = $module['account']; | ||
$repo = $module['repo']; | ||
|
||
// Fetch existing rulesets | ||
$rulesets = github_api("https://api.github.com/repos/$account/$repo/rulesets"); | ||
|
||
print_r($rulesets);die; | ||
|
||
foreach ($rulesets as $key => $label) { | ||
// $label is an array, for example: | ||
// 'id' => 427423377 | ||
// 'node_id' => MDU6TGFiZWw0Mjc0MjMzNzc=" | ||
// 'url' => "https://api.github.com/repos/silverstripe/silverstripe-config/labels/affects/v4" | ||
// 'name' => "affects/v4" | ||
// 'color' => "5319e7" | ||
// 'default' => false | ||
// 'description' => NULL | ||
$url = $label['url']; | ||
$name = $label['name']; // e.g. 'affects/v4' | ||
} | ||
output_repos_with_labels_updated(); | ||
return Command::SUCCESS; | ||
}; |
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