Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add update-js script #18

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
}
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.
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

* 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);
}