Skip to content

Commit

Permalink
Setup the dynamic "current epoch" calculation in action
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazs-flare committed Oct 4, 2023
1 parent 563a046 commit 883434e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/calculate-epoch.js
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 12 additions & 1 deletion .github/workflows/scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit 883434e

Please sign in to comment.