According to the docs, I can use the following syntax for running the CI on a schedule:
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '*/15 * * * *'
What if I want two crons? What's the syntax for this?
Add a cron definiton below the first
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 * * * *'
- cron: '*/10 5 * * *'
Responding to @Nasif's question on the accepted answer:
will all the jobs defined in the script run on both these schedules? Or, can I customize which jobs follow which cron?
Yes, I believe they will. However, if you want to run different tasks on different cron's, you can do the following (from the GH Docs):
on:
schedule:
- cron: '30 5 * * 1,3'
- cron: '30 5 * * 2,4'
jobs:
test_schedule:
runs-on: ubuntu-latest
steps:
- name: Not on Monday or Wednesday
if: github.event.schedule != '30 5 * * 1,3'
run: echo "This step will be skipped on Monday and Wednesday"
- name: Every time
run: echo "This step will always run"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With