Trigger a GH Action ANDing both a schedule and pushed changes

Hi all,

I’ve a large codebase, which is quite heavy and time-consuming to rebuild (yes, I should split it into smaller units, but this is the real world, where we need to live with those legacy dinosaurs). Because of that, I’d like my CI to build it once or twice a day only, and only if changes have been pushed since the last build.

Is that possible in GH Actions? I’m migrating from Travis and there that feature wasn’t available (as far as I know) there. So, so far I’ve realised it by having a build script that is called at every scheduled time and checks if there are GH changes in the last n hours (details here). This works, but has a few disadvantages: duplicated code and many builds that, while they’re not real build, they still bring up a whole VM, just to say ‘nothing to do right now’, and are reported in the CI log.

Thanks in advance

:wave: Hey @marco-brandizi,

You solution of using a script on a schedule to detect changes is what I’d recommend.

If you want to differentiate the real builds from the ones checking for duplicates, you could separate those out into two separate workflows.

  1. A workflow on a schedule to check for changes
  2. A workflow triggered via workflow_dispatch by the first workflow to build your repository

https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch

1 Like

Many thanks, @joshmgross, that’s very interesting, it improves things, though I wish the trigger-upon-changes feature was added to Actions.

1 Like