From 087b7272d52ebcefde40471837e8c985ab213da8 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 8 May 2024 12:54:44 +1200 Subject: [PATCH] ENH Disable dispatch for branches on previous major --- README.md | 10 ++++++++-- action.yml | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59d60f9..32a0666 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ Used to trigger CI workflows on a schedule. This workflow allows multiple branches to have CI workflows run on a schedule, rather than just the default branch. -For modules that are to be scheduled once per week, the cron must be run two times per week on consecutive days. This is done because there is logic in action.yml to run one job on the CMS 4 branches on "even" days of the week and CMS 5 branches on "odd" days of the week. +For modules that are to be scheduled once per week, the cron must be run two times per week on consecutive days. This is done because there is logic in action.yml to run one job for the latest patch branch on the previous major on "even" days of the week and the next minor branch for the current major on "odd" days of the week. -For builds that are to be scheduled once per day, specifically `silverstripe/installer` and `silverstripe/recipe-kitchen-sink`, the cron must be run two times per day on consecutive hours, because for these modules CMS 4 branches are run on "even" hours and CMS 5 branches are run on "odd" hours. +For builds that are to be scheduled once per day, specifically `silverstripe/installer` and `silverstripe/recipe-kitchen-sink`, the cron must be run two times per day on consecutive hours, because for these modules branches on the previous major version are run on "even" hours and branches on the current major version are run on "odd" hours. + +### Disabling branches on previous major version + +If the previous major version reaches the point in its life cycle where it is only receiving security fixes and no longer needs the cron job to run, it can be disabled by setting `RUN_BRANCHES_ON_PREVIOUS_MAJOR: "false"` in the `Check if should dispatch workflow` step in `actions.yml`. + +Remember to set this to `true` when a new major version is released. ### Usage diff --git a/action.yml b/action.yml index 857f6be..e8ba3ee 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,18 @@ runs: fi echo "type=$type" >> $GITHUB_OUTPUT + - name: Check if should dispatch workflow + shell: bash + env: + RUN_BRANCHES_ON_PREVIOUS_MAJOR: "false" + TYPE: ${{ steps.gettype.outputs.type }} + run: | + major_type=$(echo $TYPE | cut -d "," -f 1) + if [[ $RUN_BRANCHES_ON_PREVIOUS_MAJOR == "false" ]] && [[ $major_type == "previous" ]]; then + echo "Workflow is configured to not dispatch workflow for branches on previous major. Exiting." + exit 0 + fi + - name: Get branch id: getbranch shell: bash