Created
September 3, 2025 20:55
-
-
Save watadarkstar/108c790267d757fa70420148708019b8 to your computer and use it in GitHub Desktop.
.github/workflows /scheduled.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Daily cron job at noon EST and 4PM EST | |
on: | |
schedule: | |
# minute, hour, day of month, month, day of week | |
# runs at 12:00 EST and 4:00 EST Monday through Friday | |
- cron: "0 20,21,16,17 * * 1-5" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
cron: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check local time | |
id: check_local_time | |
env: | |
TRIGGER: ${{ github.event_name }} | |
run: | | |
echo "Trigger: ${TRIGGER}" | |
echo "Checking daylight saving time America/New_York = $(TZ="America/New_York" date +%H)" | |
if [[ ${TRIGGER} == 'schedule' ]]; then | |
if [ $(TZ="America/New_York" date +%H) -eq '16' ] || [ $(TZ="America/New_York" date +%H) -eq '12' ]; then | |
echo 'Time to run!' | |
else | |
echo "It's not local time in America/New_York. Waiting for next execution..." | |
exit 1 | |
fi | |
else | |
echo 'Trigger is not cron, omitting time check!' | |
fi | |
- name: Daily cron job | |
run: | | |
curl --request GET \ | |
--url 'https://example.com/endpoint' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment