name: Scheduled Job
on:
schedule:
- cron: "*/5 * * * *" # Runs every 5 minutes
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
workflow_dispatch: {}
jobs:
scheduled-job:
runs-on: ubuntu-latest
steps:
- name: Print Current Time
run: echo "The current time is $(date)
The above github actions workflow YAML is not triggering for every 5 minutes when I pushed the feature branch and raise a PR
Please guide me the reason why the CRON job is not triggered?
It does not trigger for a feature branch because the documentation clearly states this:
This part should for sure trigger for a push to the
mainbranch though:and that might be redundant with the whole cron schedule. I'm not sure if a scheduled workflow will trigger for commits that have already been verified on push.
Pull request against the
mainbranch should also automatically trigger without the whole cron part:If none of these trigger, first make sure your default branch really is
mainand and notmaster.mainis the new default at GH, but your local git installation might still usemaster.See the documentation for more: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule