mirror of
https://github.com/0xMarcio/cve.git
synced 2026-10-27 16:51:03 +00:00
GitHub's cron scheduler creates this repository's scheduled runs four to five hours late and drops the slots in between, so the hourly Hot CVEs refresh cannot come from a cron. A workflow_dispatch call creates a run within seconds, so a pacemaker workflow now sleeps until the next :05, fires the refresh and its own successor, and keeps time by itself. Its cron only restarts the chain if a link fails. Hot CVEs loses its cron and the gate that was there to coexist with an external trigger; nothing outside GitHub is involved any more.
38 lines
1.3 KiB
YAML
38 lines
1.3 KiB
YAML
name: Pacemaker
|
|
|
|
# GitHub's cron scheduler creates this repository's scheduled runs four to
|
|
# five hours late and drops the slots in between, so the hourly refresh cannot
|
|
# come from a cron. A workflow_dispatch call creates a run within seconds, so
|
|
# each pacemaker run sleeps until the next :05, fires the Hot CVEs refresh and
|
|
# its own successor, and the chain keeps time by itself. The cron below only
|
|
# restarts the chain if a link ever fails; while the chain is alive the
|
|
# concurrency group holds the extra run back and the next link cancels it.
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '7 * * * *'
|
|
|
|
permissions:
|
|
actions: write
|
|
|
|
concurrency:
|
|
group: pacemaker
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
tick:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 70
|
|
steps:
|
|
- name: Sleep until the next :05, then fire the hourly refresh
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
now=$(date -u +%s)
|
|
next=$(( now / 3600 * 3600 + 300 ))
|
|
[ "$next" -gt "$now" ] || next=$(( next + 3600 ))
|
|
echo "Sleeping $(( (next - now) / 60 )) minutes until $(date -u -d @"$next" +%H:%M) UTC"
|
|
sleep $(( next - now ))
|
|
gh workflow run hot_cves.yml --ref main
|
|
gh workflow run pacemaker.yml --ref main
|