Skip to content

Commit

Permalink
Merge pull request #18 from creative-commoners/pulls/main/update-js
Browse files Browse the repository at this point in the history
NEW Add update-js script
  • Loading branch information
GuySartorelli authored Aug 29, 2023
2 parents 541cf4c + d04a2e1 commit 03249f9
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
18 changes: 14 additions & 4 deletions funcs_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,27 @@ function supported_modules($cmsMajor)
}

/**
* Hardcoded list of additional repositories to standardise (e.g. silverstripe/gha-*)
* Hardcoded list of non-supported, additional repositories to standardise (e.g. silverstripe/gha-*)
*
* Repositories in this list should only have a single supported major version
* This will only be included if the $cmsMajor is the CURRENT_CMS_MAJOR
*/
function extra_repositories()
{
$modules = [];
// iterating to page 7 should be enough to get all the repos well into the future
for ($i = 0; $i < 7; $i++) {
$json = github_api("https://api.github.com/orgs/silverstripe/repos?per_page=100&page=$i");
// iterating to page 10 will be enough to get all the repos well into the future
for ($i = 0; $i < 10; $i++) {
$path = "_data/extra_repositories-$i.json";
if (file_exists($path)) {
info("Reading local data from $path");
$json = json_decode(file_get_contents($path), true);
} else {
$json = github_api("https://api.github.com/orgs/silverstripe/repos?per_page=100&page=$i");
file_put_contents($path, json_encode($json, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
}
if (empty($json)) {
break;
}
foreach ($json as $repo) {
if ($repo['archived']) {
continue;
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions scripts/cms-any/license.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions scripts/cms-any/update-js.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
$account = module_account();

// run at a random hour of the day
$runOnHour = predictable_random_int(23);
// run at a random minute of the hour rounded to 5 minutes
$runOnMinute = predictable_random_int(11) * 5;
// run on a 1st of the month
$runOnDay = 1;

$content = <<<EOT
name: Update JS
on:
workflow_dispatch:
# Run on a schedule of once per quarter
schedule:
- cron: '$runOnMinute $runOnHour $runOnDay */3 *'
jobs:
update-js:
name: Update JS
# Only run cron on the $account account
if: (github.event_name == 'schedule' && github.repository_owner == '$account') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Update JS
uses: silverstripe/gha-update-js@v1
EOT;

if (check_file_exists('package.json')) {
write_file_even_if_exists('.github/workflows/update-js.yml', $content);
}

0 comments on commit 03249f9

Please sign in to comment.