Trigger action on.schedule only if there are changes to the branch

I would like to run an Action once every 24 hours, only if commits have been made to the target branch in the last 24 hours (or since the last run). This is for calculating code coverage on a large repo, which takes about 20-30 mins.

I can find documentation for on.schedule (https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule) but not for checking the date/time of the latest commit.

1 Like

Hey @nheath99, this is not a functionary that is supported out of the box. I suggest adding in an additional piece to the action that uses Python or another language to check the git contents to see if there’s a commit in the last 24 hours. 

1 Like

Hi @nheath99 ,

You can use ‘schedule’ event, and in the job check the last commit time via script in the link: https://gist.github.com/jasonrudolph/1810768.

If the last commit is in 24hours, execute your steps, otherwise skip it(use if expression to skip the job ).

Thanks.

2 Likes