-
Notifications
You must be signed in to change notification settings - Fork 5
51 lines (44 loc) · 1.86 KB
/
v2-schedule-scoring.yml
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
name: Schedule Scoring V2
on:
workflow_dispatch:
schedule:
- cron: '50 0/1 * * *'
jobs:
trigger_scoring_v2_if_needed:
name: Schedule Scoring V2
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@master
with:
fetch-depth: 20
- name: Check epoch timing
run: |
epoch_info=$(curl -sfLS "http://api.mainnet-beta.solana.com" -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}')
current_epoch=$(<<<"$epoch_info" jq '.result.epoch' -r)
slot_index=$(<<<"$epoch_info" jq '.result.slotIndex' -r)
last_v2_scoring_epoch_from_dir=$(find scoring-v2 -type d | sort -n | tail -1 | cut -d/ -f2 | cut -d. -f1)
last_v2_scoring_epoch_from_git=$(gh pr list --state open --json headRefName,isCrossRepository --jq '.[] | select(.isCrossRepository == false) | .headRefName' | grep scoring/ | sort -n | tail -1 | cut -d/ -f2| cut -d. -f1)
echo "Last V2 scoring epoch (git): $last_v2_scoring_epoch_from_git"
echo "Last V2 scoring epoch (dir): $last_v2_scoring_epoch_from_dir"
echo "Current epoch: $current_epoch"
echo "Current slot: $slot_index"
if (( slot_index < 10000 ))
then
echo "Too early in the epoch!"
exit 0
fi
if ! [[ -z $last_v2_scoring_epoch_from_dir ]] && (( last_v2_scoring_epoch_from_dir == current_epoch ))
then
echo "Scoring already run and merged!"
exit 0
fi
if ! [[ -z $last_v2_scoring_epoch_from_git ]] && (( last_v2_scoring_epoch_from_git == current_epoch ))
then
echo "Scoring already in PR!"
exit 0
fi
echo "Triggering the V2 scoring pipeline..."
gh workflow run v2-prepare-scoring.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}