|
1 | | -name: "Calculate rewards" |
| 1 | +# name: "Calculate rewards" |
2 | 2 |
|
3 | | -on: |
4 | | - schedule: |
5 | | - - cron: '30 7 * * 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 (Last epoch if of-four)" |
11 | | - type: number |
12 | | - reward_amount_epoch_wei: |
13 | | - description: "Reward amount (in wei)" |
14 | | - type: number |
15 | | - trigger_generate_report_workflow: |
16 | | - description: "Run github pages deployment workflow" |
17 | | - type: string |
18 | | - required: true |
19 | | - default: 'true' |
| 3 | +# on: |
| 4 | +# # schedule: |
| 5 | +# # - cron: '30 7 * * 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 (Last epoch if of-four)" |
| 11 | +# type: number |
| 12 | +# reward_amount_epoch_wei: |
| 13 | +# description: "Reward amount (in wei)" |
| 14 | +# type: number |
| 15 | +# trigger_generate_report_workflow: |
| 16 | +# description: "Run github pages deployment workflow" |
| 17 | +# type: string |
| 18 | +# required: true |
| 19 | +# default: 'true' |
20 | 20 |
|
21 | 21 |
|
22 | | -permissions: |
23 | | - contents: write |
24 | | - actions: write |
| 22 | +# permissions: |
| 23 | +# contents: write |
| 24 | +# actions: write |
25 | 25 |
|
26 | | -jobs: |
27 | | - process-staking-rewards: |
28 | | - runs-on: ubuntu-latest |
29 | | - steps: |
30 | | - - uses: actions/checkout@v4 |
31 | | - - uses: actions/setup-node@v3 |
32 | | - with: |
33 | | - node-version: 20 |
34 | | - - name: Install jq |
35 | | - run: sudo apt update -y && sudo apt install jq moreutils -y |
36 | | - - name: Install node modules |
37 | | - run: yarn install --frozen-lockfile |
38 | | - - name: Calculate epoch vars |
39 | | - run: | |
40 | | - export REWARD_EPOCH_DEFINED="${{ github.event.inputs.first_reward_epoch }}" |
41 | | - export REWARD_EPOCH_CALCULATED="$(node .github/workflows/get-current-reward-epoch.js)" |
42 | | - export USE_REWARD_EPOCH="${REWARD_EPOCH_DEFINED:-$REWARD_EPOCH_CALCULATED}" |
43 | | - echo "USE_REWARD_EPOCH=$USE_REWARD_EPOCH" >> "$GITHUB_ENV" |
| 26 | +# jobs: |
| 27 | +# process-staking-rewards: |
| 28 | +# runs-on: ubuntu-latest |
| 29 | +# steps: |
| 30 | +# - uses: actions/checkout@v4 |
| 31 | +# - uses: actions/setup-node@v3 |
| 32 | +# with: |
| 33 | +# node-version: 20 |
| 34 | +# - name: Install jq |
| 35 | +# run: sudo apt update -y && sudo apt install jq moreutils -y |
| 36 | +# - name: Install node modules |
| 37 | +# run: yarn install --frozen-lockfile |
| 38 | +# - name: Calculate epoch vars |
| 39 | +# run: | |
| 40 | +# export REWARD_EPOCH_DEFINED="${{ github.event.inputs.first_reward_epoch }}" |
| 41 | +# export REWARD_EPOCH_CALCULATED="$(node .github/workflows/get-current-reward-epoch.js)" |
| 42 | +# export USE_REWARD_EPOCH="${REWARD_EPOCH_DEFINED:-$REWARD_EPOCH_CALCULATED}" |
| 43 | +# echo "USE_REWARD_EPOCH=$USE_REWARD_EPOCH" >> "$GITHUB_ENV" |
44 | 44 |
|
45 | | - export USE_FIRST_REWARD_EPOCH="$((${USE_REWARD_EPOCH} - 3))" |
46 | | - echo "USE_FIRST_REWARD_EPOCH=${USE_FIRST_REWARD_EPOCH}" >> "$GITHUB_ENV" |
| 45 | +# export USE_FIRST_REWARD_EPOCH="$((${USE_REWARD_EPOCH} - 3))" |
| 46 | +# echo "USE_FIRST_REWARD_EPOCH=${USE_FIRST_REWARD_EPOCH}" >> "$GITHUB_ENV" |
47 | 47 |
|
48 | | - echo "EPOCH_OF4_if0=$(( $(( $USE_REWARD_EPOCH - 1 )) % 4 ))" >> "$GITHUB_ENV" |
| 48 | +# echo "EPOCH_OF4_if0=$(( $(( $USE_REWARD_EPOCH - 1 )) % 4 ))" >> "$GITHUB_ENV" |
49 | 49 |
|
50 | | - - name: Set reward amount wei overwrite |
51 | | - if: github.event.inputs.reward_amount_epoch_wei != '' |
52 | | - run: jq --raw-output --monochrome-output --argjson amount "${{ github.event.inputs.reward_amount_epoch_wei }}" '.REWARD_AMOUNT_EPOCH_WEI = $amunt' configs/networks/flare.json | sponge configs/networks/flare.json |
| 50 | +# - name: Set reward amount wei overwrite |
| 51 | +# if: github.event.inputs.reward_amount_epoch_wei != '' |
| 52 | +# run: jq --raw-output --monochrome-output --argjson amount "${{ github.event.inputs.reward_amount_epoch_wei }}" '.REWARD_AMOUNT_EPOCH_WEI = $amunt' configs/networks/flare.json | sponge configs/networks/flare.json |
53 | 53 |
|
54 | | - - name: Process staking rewards for ${{ env.USE_REWARD_EPOCH }} |
55 | | - run: | |
56 | | - jq --raw-output --monochrome-output '.NUM_EPOCHS = 1' configs/networks/flare.json | sponge configs/networks/flare.json |
57 | | - jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json |
58 | | - yarn run process-staking-rewards |
| 54 | +# - name: Process staking rewards for ${{ env.USE_REWARD_EPOCH }} |
| 55 | +# run: | |
| 56 | +# jq --raw-output --monochrome-output '.NUM_EPOCHS = 1' configs/networks/flare.json | sponge configs/networks/flare.json |
| 57 | +# jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json |
| 58 | +# yarn run process-staking-rewards |
59 | 59 |
|
60 | | - - name: Combine rewards for [epoch ${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}] |
61 | | - if: env.EPOCH_OF4_if0 == 0 |
62 | | - run: | |
63 | | - jq --raw-output --monochrome-output '.NUM_EPOCHS = 4' configs/networks/flare.json | sponge configs/networks/flare.json |
64 | | - jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json |
65 | | - yarn sum-staking-rewards |
| 60 | +# - name: Combine rewards for [epoch ${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}] |
| 61 | +# if: env.EPOCH_OF4_if0 == 0 |
| 62 | +# run: | |
| 63 | +# jq --raw-output --monochrome-output '.NUM_EPOCHS = 4' configs/networks/flare.json | sponge configs/networks/flare.json |
| 64 | +# jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json |
| 65 | +# yarn sum-staking-rewards |
66 | 66 |
|
67 | | - - name: Commit generated-files |
68 | | - run: | |
69 | | - git config --global user.name 'Reward scripts automation' |
70 | | - git config --global user.email 'flare-foundation-reward-scripts-automation@users.noreply.github.com' |
71 | | - git add generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }} |
72 | | - if [ "$EPOCH_OF4_if0" -eq 0 ]; then git add generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json; fi |
73 | | - git commit -m "Processed staking rewards for epoch ${{ env.USE_REWARD_EPOCH }}" && git push || echo "No changes were present, failed to commit, proceeding..." |
| 67 | +# - name: Commit generated-files |
| 68 | +# run: | |
| 69 | +# git config --global user.name 'Reward scripts automation' |
| 70 | +# git config --global user.email 'flare-foundation-reward-scripts-automation@users.noreply.github.com' |
| 71 | +# git add generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }} |
| 72 | +# if [ "$EPOCH_OF4_if0" -eq 0 ]; then git add generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json; fi |
| 73 | +# git commit -m "Processed staking rewards for epoch ${{ env.USE_REWARD_EPOCH }}" && git push || echo "No changes were present, failed to commit, proceeding..." |
74 | 74 |
|
75 | | - - name: Upload artifacts |
76 | | - uses: actions/upload-artifact@v3 |
77 | | - with: |
78 | | - name: staking-rewards |
79 | | - path: | |
80 | | - generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }} |
81 | | - generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json |
| 75 | +# - name: Upload artifacts |
| 76 | +# uses: actions/upload-artifact@v3 |
| 77 | +# with: |
| 78 | +# name: staking-rewards |
| 79 | +# path: | |
| 80 | +# generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }} |
| 81 | +# generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json |
82 | 82 |
|
83 | | - - name: Trigger "generate report" workflow |
84 | | - if: github.event.inputs.trigger_generate_report_workflow == 'true' || github.event.inputs.trigger_generate_report_workflow == '' |
85 | | - env: |
86 | | - GH_TOKEN: ${{ github.token }} |
87 | | - run: gh workflow run "Generate report" -f first_reward_epoch=${{ env.USE_REWARD_EPOCH }} |
| 83 | +# - name: Trigger "generate report" workflow |
| 84 | +# if: github.event.inputs.trigger_generate_report_workflow == 'true' || github.event.inputs.trigger_generate_report_workflow == '' |
| 85 | +# env: |
| 86 | +# GH_TOKEN: ${{ github.token }} |
| 87 | +# run: gh workflow run "Generate report" -f first_reward_epoch=${{ env.USE_REWARD_EPOCH }} |
0 commit comments