Trigger action on.schedule only if there are changes to the branch #27128
-
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. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
you can do something like this:
for example:
|
Beta Was this translation helpful? Give feedback.
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.