Setup the dynamic "current epoch" calculation in action #5
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: "Rewards" | |
on: | |
push: | |
schedule: | |
- cron: '0 9 * * 1' # Every Monday at 11:00 +2 | |
- cron: '0 6 * * 5' # Every Friday at 08:00 +2 | |
workflow_dispatch: | |
inputs: | |
first_reward_epoch: | |
description: "First reward epoch" | |
type: number | |
jobs: | |
process-staking-rewards: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install node modules | |
run: yarn install --frozen-lockfile | |
- name: Run process-staking-rewards | |
run: yarn run process-staking-rewards | |
- name: Calculate current epoch | |
if: "${{ github.event.inputs.first_reward_epoch == '' }}" | |
run: | | |
export FIRST_REWARD_EPOCH="$(node .github/workflows/calculate-epoch.js)" | |
jq --arg epoch "$FIRST_REWARD_EPOCH" '.FIRST_REWARD_EPOCH = $epoch' configs/networks/flare.json > configs/networks/flare.json | |
- name: Replace FIRST_REWARD_EPOCH | |
if: "${{ github.event.inputs.first_reward_epoch != '' }}" | |
run: | | |
jq --arg epoch "${{ github.event.inputs.first_reward_epoch }}" '.FIRST_REWARD_EPOCH = $epoch' configs/networks/flare.json > configs/networks/flare.json | |
- name: Print out flare.json | |
run: cat configs/networks/flare.json | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: staking rewards reports | |
path: generated-files/ |