123 words
1 minute
Running different steps on a schedule

Running different steps on a schedule#

Say you have a workflow that runs hourly, but once a day you want the workflow to run slightly differently - without duplicating the entire workflow.

Thanks to @BrightRan, here’s the solution. Use the following pattern in an if: condition for a step:

github.event_name == 'schedule' && github.event.schedule == '20 17 * * *'

Longer example:

name: Fetch updated data and deploy
on:
push:
schedule:
- cron: '5,35 * * * *'
- cron: '20 17 * * *'
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
# ...
- name: Download existing .db files
if: |-
!(github.event_name == 'schedule' && github.event.schedule == '20 17 * * *')
env:
DATASETTE_TOKEN: ${{ secrets.DATASETTE_TOKEN }}
run: |-
datasette-clone https://biglocal.datasettes.com/ dbs -v --token=$DATASETTE_TOKEN

I used this here, see #11.

Running different steps on a schedule
https://mranv.pages.dev/posts/running-different-steps-on-a-schedule/
Author
Anubhav Gain
Published at
2024-09-30
License
CC BY-NC-SA 4.0