-
-
Save RickCogley/68caf95bbd9e56194977 to your computer and use it in GitHub Desktop.
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
<?php | |
// credential to access github, you should choose between username/password authentication or token (for two step verification accounts) | |
$githubUser = 'YOURGITHUBUSER'; | |
$githubPasswd = 'YOURGITHUBPASSWD'; | |
// or | |
//$githubToken = 'YOURGITHUBTOKEN'; | |
$githubOrganization = 'YOURGITHUBORGANIZATION'; | |
// the list of repo in your github organization you want to align | |
$repos = array( | |
'YOURREPO#1', | |
'YOURREPO#2', | |
'YOURREPO#3', | |
// ... | |
); | |
// Add, remove, or set names and colors of issue labels as you wish | |
$arrayLabels = array( | |
'a:admin' => 'c7def8', | |
'a:doc' => 'c7def8', | |
'a:user' => 'c7def8', | |
'e:1' => 'd4c5f9', | |
'e:2' => 'd4c5f9', | |
'e:3' => 'd4c5f9', | |
'i:improvement' => 'fad8c7', | |
'i:progress-25' => 'fad8c7', | |
'i:progress-50' => 'fad8c7', | |
'i:progress-75' => 'fad8c7', | |
'p:blocker' => 'e11d21', | |
'p:critical' => 'f7c6c7', | |
'p:high' => 'f7c6c7', | |
'p:low' => 'f7c6c7', | |
's:cant-reproduce' => 'fef2c0', | |
's:help-needed' => 'fef2c0', | |
's:in-pull-request' => 'fef2c0', | |
's:needs-discussion' => 'fbca04', | |
't:bug' => 'bfe5bf', | |
't:bugsnag' => 'bfe5bf', | |
't:feature' => 'bfe5bf', | |
't:idea' => 'bfe5bf', | |
't:invalid' => 'bfe5bf', | |
't:question' => 'bfe5bf', | |
't:refactor' => 'bfe5bf', | |
't:support' => 'bfe5bf', | |
't:task' => 'bfe5bf', | |
't:ux' => 'bfe5bf' | |
); | |
foreach( $repos as $repo ) { | |
foreach( $arrayLabels as $name => $color ) { | |
$labelToSet = '\'{ "name": "' . $name .'","color": "' . $color . '" }\''; | |
if (isset($githubToken)) { | |
system( 'curl -u ' . $githubToken . ':x-oauth-basic https://api.github.com/repos/' . $githubOrganization . '/' . $repo . '/labels -X POST --data ' . $labelToSet ); | |
} else { | |
system( 'curl -u "' . $githubUser . ':' . $githubPasswd . '" https://api.github.com/repos/' . $githubOrganization . '/' . $repo . '/labels -X POST --data ' . $labelToSet ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment