Distinct job for each schedule #25662
-
I have a backup.yml workflow which I use for automated database backup. I’ve started with a workflow that schedules hourly, however, I want to include in a single workflow multiple backup jobs. Hourly, daily, weekly, etc. Is there a way for me to conditionally skip a job in the workflow if the workflow was not triggered by the desired schedule? For example:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi @mhitza , Thank you for being here! If you’d like a single workflow to include multiple schedule jobs, you can add multiple ‘corn’ expression for schedule event, sample as below, you can use ‘cron: ‘*/60 * * * *’’ for hourly…etc.(doc here)
For different schedule, the github has different context, for intance, 7mins schedule: You can use if expression to conditionally skip the other jobs then.
Hope it helps. |
Beta Was this translation helpful? Give feedback.
-
Adding this to the official docs would be mighty helpful! |
Beta Was this translation helpful? Give feedback.
-
Noting 154811 and 167893 which are similar questions. @weide-zhou thanks for sharing a solution that allows:
The use case for 2 (conditional behavior) would be assisted with the ability to assign a unique ID to each schedule.
Then we could add conditions based on |
Beta Was this translation helpful? Give feedback.
-
Any reasoning on using |
Beta Was this translation helpful? Give feedback.
Hi @mhitza ,
Thank you for being here! If you’d like a single workflow to include multiple schedule jobs, you can add multiple ‘corn’ expression for schedule event, sample as below, you can use ‘cron: ‘*/60 * * * *’’ for hourly…etc.(doc here)
For different schedule, the github has different context, for intance, 7mins schedule:
You can use if expression to conditionally skip the other jobs then.