Skip to content

Commit

Permalink
Merge pull request #64 from creative-commoners/pulls/main/various-pro…
Browse files Browse the repository at this point in the history
…blems

Fix various problems (multiple commits)
  • Loading branch information
emteknetnz authored Jun 18, 2024
2 parents b666beb + 849fbff commit 554915b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
22 changes: 20 additions & 2 deletions funcs_scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ function is_docs()
return $moduleName === 'developer-docs' || $moduleName === 'silverstripe-userhelp-content';
}

/**
* Determine if the module being processed is commercially supported
*
* Example usage:
* is_supported()
*/
function is_supported()
{
global $GITHUB_REF;
return in_array(
$GITHUB_REF,
array_column(
MetaData::getAllRepositoryMetaData()[MetaData::CATEGORY_SUPPORTED],
'github'
)
);
}

/**
* Determine if the module being processed is a gha-* repository e.g. gha-ci
* aka "WORKFLOW"
Expand All @@ -263,7 +281,7 @@ function is_gha_repository()
* Determine if the module being processed is "TOOLING"
*
* Example usage:
* is_gha_repository()
* is_tooling()
*/
function is_tooling()
{
Expand All @@ -281,7 +299,7 @@ function is_tooling()
* Determine if the module being processed is "MISC"
*
* Example usage:
* is_gha_repository()
* is_misc()
*/
function is_misc()
{
Expand Down
4 changes: 2 additions & 2 deletions scripts/cms-any/add-prs-to-project.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$content = <<<EOT
$content = <<<'EOT'
name: Add new pull requests to a github project
on:
Expand All @@ -25,7 +25,7 @@
EOT;

$actionPath = '.github/workflows/add-prs-to-project.yml';
$shouldHaveAction = module_account() === 'silverstripe' && is_module() && !module_is_recipe();
$shouldHaveAction = module_account() === 'silverstripe' && is_supported() && is_docs() || (is_module() && !module_is_recipe());

if ($shouldHaveAction) {
write_file_even_if_exists($actionPath, $content);
Expand Down
14 changes: 13 additions & 1 deletion update_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
global $MODULE_DIR, $GITHUB_REF, $OUT, $PRS_CREATED, $REPOS_WITH_PRS_CREATED;
$OUT = $output;

$reposMissingBranch = [];

// validate system is ready
validate_system();

Expand Down Expand Up @@ -146,8 +148,10 @@
$branchOption
);
}
// If we can't identify an appropriate branch, add to a list so we can report about it later.
if (!in_array($branchToCheckout, $allBranches)) {
error("Could not find branch to checkout for $repo using --branch=$branchOption");
$reposMissingBranch[] = $repo;
continue;
}
}
cmd("git checkout $branchToCheckout", $MODULE_DIR);
Expand Down Expand Up @@ -219,5 +223,13 @@
}
output_repos_with_prs_created();
output_prs_created();

// Report about any repos for which we couldn't find the right branch.
if (count($reposMissingBranch)) {
$reposString = implode("\n- ", $reposMissingBranch);
warning("Could not find branch to checkout for the following repos using --branch=$branchOption:\n- $reposString");
return Command::FAILURE;
}

return Command::SUCCESS;
};

0 comments on commit 554915b

Please sign in to comment.