Repository navigation
54 lines (50 loc) · 2.23 KB
/
Copy pathclock.yml
File metadata and controls
54 lines (50 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: clock
# Starts the daily jobs at the right minute (qtrade/clock.py): GitHub's own schedules for this
# repository fire late or not at all. A clock run stays up ~5.5 hours and dispatches each job
# once per slot; before it ends it starts the next clock, so one is always running. The hourly
# schedule is only a watchdog that restarts the chain if it ever breaks.
on:
schedule:
- cron: "3 * * * *"
workflow_dispatch:
inputs:
successor:
description: "started by the previous clock (never stands aside)"
default: "false"
permissions:
contents: read
actions: write # dispatches the jobs and the next clock
jobs:
clock:
runs-on: ubuntu-latest
timeout-minutes: 350
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Stand aside if a clock is already running
id: check
run: |
# the previous clock starts this one while it is itself still finishing, so it would always look
# "running": a successor never stands aside (on 2026-10-30 the chain died exactly that way)
if [ "${{ inputs.successor }}" = "true" ]; then echo "run=true" >> "$GITHUB_OUTPUT"; exit 0; fi
RUNNING=$(gh run list -R "${{ github.repository }}" --workflow clock.yml --status in_progress \
--json databaseId -q "[.[] | select(.databaseId != ${{ github.run_id }})] | length")
if [ "${RUNNING:-0}" -gt 0 ]; then echo "a clock is running - nothing to do"; echo "run=false" >> "$GITHUB_OUTPUT"
else echo "run=true" >> "$GITHUB_OUTPUT"; fi
- uses: actions/checkout@v4
if: steps.check.outputs.run == 'true'
- uses: actions/setup-python@v5
if: steps.check.outputs.run == 'true'
with:
python-version: "3.11"
cache: pip
- if: steps.check.outputs.run == 'true'
run: pip install -r requirements.txt
- name: Tick
if: steps.check.outputs.run == 'true'
run: python -m qtrade.clock --hours 5.5
- name: Start the next clock
if: always() && steps.check.outputs.run == 'true'
run: |
gh workflow run clock.yml -R "${{ github.repository }}" --ref "${{ github.ref_name }}" -f successor=true
echo "next clock started"