Schedule once an hour, but do something different once a day?

I have a task that runs hourly - but I want to run it very slightly differently once a day: I want to skip one of the steps in it every 24 hours.

Any neat mechanisms for me to do that?

@simonw ,

You can try the following configurations in your workflow:

on:
  schedule:
    - cron: '0 1-23 * * *'
    - cron: '0 0 * * *'

jobs:
  test_schedule:
    name: Test schedule
    runs-on: ubuntu-latest
    steps:
      - name: Skip this step every 24 hours
        if: github.event_name == 'schedule' && github.event.schedule != '0 0 * * *'
        run: echo "This step will be skipped every 24 hours"

1) The first cron ’ 0 1-23 * * *’ will trigger the workflow hourly from the 1st hour to 23th hour.

2) The second cron ’ 0 0 * * *’ will only trigger the workflow at 00:00 UTC.

3) The property " github.event.schedule" of the github context returns the cron of the schedule that triggers the current workflow run.

4) On the step that need to be skipped every 24 hours, set the if conditional  to check which cron of the schedule triggers the current workflow run.  If the cron is not ’ 0 0 * * *’, execute this step, otherwise skip this step.

2 Likes

Thanks very much - this looks like exactly the solution I need.

It worked! https://github.com/simonw/big-local-datasette/issues/11

1 Like

Just wanted to say thank @brightran! Was looking to figure out the payloads available on github.event and this helped me no end!