-
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
98fe0ab
commit 8ca3e2d
Showing
10 changed files
with
352 additions
and
73 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
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
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
{ | ||
"require": { | ||
"php": ">=7.4", | ||
"php": ">=8.1", | ||
"symfony/console": "^6.3", | ||
"symfony/process": "^6.3" | ||
"symfony/process": "^6.3", | ||
"panlatent/cron-expression-descriptor": "^1" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5" | ||
"phpunit/phpunit": "^9.6" | ||
} | ||
} |
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
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
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
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
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 @@ | ||
<?php | ||
|
||
// run on a day of the month up to the 28th | ||
$runOnDay = predictable_random_int(27, 1); | ||
// 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; | ||
|
||
$cron = "$runOnMinute $runOnHour $runOnDay * *"; | ||
$humanCron = human_cron($cron); | ||
$account = module_account(); | ||
|
||
$content = <<<EOT | ||
name: Keepalive | ||
on: | ||
# $humanCron | ||
schedule: | ||
- cron: '$cron' | ||
workflow_dispatch: | ||
jobs: | ||
keepalive: | ||
name: Keepalive | ||
# 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: Keepalive | ||
uses: silverstripe/gha-keepalive@v1 | ||
EOT; | ||
|
||
write_file_even_if_exists('.github/workflows/keepalive.yml', $content); |
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,59 @@ | ||
<?php | ||
|
||
// run on a random day of the week | ||
$runOnDay = predictable_random_int(6); | ||
// 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; | ||
|
||
// If there's a CI workflow, offset mergeups from the CI run by 3 days | ||
if (check_file_exists('.github/workflows/dispatch-ci.yml')) { | ||
$ci = read_file('.github/workflows/dispatch-ci.yml'); | ||
preg_match("#- cron: '(.+?) (.+?) (.+?) (.+?) (.+?)'#", $ci, $matches); | ||
[$_, $minute, $hour, $day, $month, $dayOfWeek] = $matches; | ||
if ($dayOfWeek !== '*') { | ||
$days = explode(',', $dayOfWeek); | ||
$runOnDay = ($days[count($days) - 1] + 3) % 7; | ||
} | ||
if ($hour !== '*') { | ||
$hours = explode(',', $hour); | ||
$runOnHour = $hours[0]; | ||
} | ||
if ($minute !== '*') { | ||
$runOnMinute = $minute; | ||
} | ||
} | ||
|
||
$cron = "$runOnMinute $runOnHour * * $runOnDay"; | ||
$humanCron = human_cron($cron); | ||
$account = module_account(); | ||
|
||
$content = <<<EOT | ||
name: Merge-up | ||
on: | ||
# $humanCron | ||
schedule: | ||
- cron: '$cron' | ||
workflow_dispatch: | ||
jobs: | ||
merge-up: | ||
name: Merge-up | ||
# 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: Merge-up | ||
uses: silverstripe/gha-merge-up@v1 | ||
EOT; | ||
|
||
// rename any existing misnamed merge-ups.yml to merge-up.yml | ||
if (check_file_exists('.github/workflows/merge-ups.yml')) { | ||
rename_file_if_exists('.github/workflows/merge-ups.yml', '.github/workflows/merge-up.yml'); | ||
} | ||
|
||
if (!module_is_recipe()) { | ||
write_file_even_if_exists('.github/workflows/merge-up.yml', $content); | ||
} |
Oops, something went wrong.