1+ name : " Calculate initial rewards data"
2+
3+ on :
4+ schedule :
5+ - cron : ' 30 13 * * 1' # Every Monday at 07:30 UCT
6+ - cron : ' 30 19 * * 4' # Every Thursday at 19:30 UCT
7+ workflow_dispatch :
8+ inputs :
9+ first_reward_epoch :
10+ description : " Reward epoch"
11+ type : number
12+
13+ permissions :
14+ contents : write
15+ actions : write
16+
17+ jobs :
18+ process-staking-rewards :
19+ runs-on : ubuntu-latest
20+ steps :
21+ - uses : actions/checkout@v4
22+ - uses : actions/setup-node@v3
23+ with :
24+ node-version : 20
25+ - name : Install jq
26+ run : sudo apt update -y && sudo apt install jq moreutils -y
27+ - name : Install node modules
28+ run : yarn install --frozen-lockfile
29+ - name : Calculate epoch vars
30+ run : |
31+ export REWARD_EPOCH_DEFINED="${{ github.event.inputs.first_reward_epoch }}"
32+ export REWARD_EPOCH_CALCULATED="$(node .github/workflows/get-current-reward-epoch.js)"
33+ export USE_REWARD_EPOCH="${REWARD_EPOCH_DEFINED:-$REWARD_EPOCH_CALCULATED}"
34+ echo "USE_REWARD_EPOCH=$USE_REWARD_EPOCH" >> "$GITHUB_ENV"
35+
36+ - name : Process initial rewards data for ${{ env.USE_REWARD_EPOCH }}
37+ run : |
38+ jq --raw-output --monochrome-output '.NUM_EPOCHS = 1' configs/networks/flare.json | sponge configs/networks/flare.json
39+ jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json
40+ yarn run process-staking-rewards
41+
42+ - name : Commit generated-files
43+ run : |
44+ git config --global user.name 'Reward scripts automation'
45+ git config --global user.email 'flare-foundation-reward-scripts-automation@users.noreply.github.com'
46+ git add generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }}
47+ git commit -m "Processed initial rewards data for epoch ${{ env.USE_REWARD_EPOCH }}" && git push || echo "No changes were present, failed to commit, proceeding..."
48+
49+ - name : Upload artifacts
50+ uses : actions/upload-artifact@v4
51+ with :
52+ name : staking-rewards
53+ path : |
54+ generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }}
0 commit comments