diff --git a/.github/workflows/calculate-epoch.js b/.github/workflows/calculate-epoch.js new file mode 100644 index 0000000..068941a --- /dev/null +++ b/.github/workflows/calculate-epoch.js @@ -0,0 +1,7 @@ +const startDate = new Date(1658430005000) + +const diffInMs = new Date() - startDate +const diff = (diffInMs / 1000 / 60 / 60) / 84 +// ( diff in hours ) `- epoch increases every 84 hours +const currentEpoch = Math.floor(diff) +console.log(currentEpoch) \ No newline at end of file diff --git a/.github/workflows/scheduled.yaml b/.github/workflows/scheduled.yaml index 24936e3..5c8863e 100644 --- a/.github/workflows/scheduled.yaml +++ b/.github/workflows/scheduled.yaml @@ -7,7 +7,7 @@ on: - cron: '0 6 * * 5' # Every Friday at 08:00 +2 workflow_dispatch: inputs: - name: + first_reward_epoch: description: "First reward epoch" type: number @@ -23,6 +23,17 @@ jobs: 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: