Schedule Scoring V2 #6153
This file contains 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: 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 }} |