Calculate and Upload KPIs #2166
This file contains hidden or 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: Calculate and Upload KPIs | |
on: | |
schedule: | |
- cron: '0 */2 * * *' # Runs at minute 0 every 2 hours | |
workflow_dispatch: | |
inputs: | |
timestamp: | |
description: 'KPIs are calculated for the reward period that includes this timestamp, from the start of the period up to this timestamp. (new Date() compatible epoch milliseconds or string)' | |
required: true | |
protocols: | |
description: 'Comma separated list of protocols to calculate KPIs for, e.g. celo-pg,scout-game-v0,lisk-v0. If not specified, KPIs will be calculated for all protocols.' | |
# Cancel same in progress run(s) of the workflow to avoid uploading outdated KPIs | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-${{ github.event_name }} | |
cancel-in-progress: true | |
jobs: | |
calculate-and-upload-KPIs: | |
name: Calculate and Upload KPIs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
- uses: google-github-actions/auth@c200f3691d83b41bf9bbd8638997a462592937ed # v2.1.13 | |
with: | |
project_id: divvi-production | |
credentials_json: ${{ secrets.DIVVI_PRODUCTION_UPLOADER_SERVICE_ACCOUNT_KEY }} | |
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
with: | |
node-version-file: 'package.json' | |
check-latest: true | |
- run: yarn | |
- name: Calculate and upload KPIs for the current reward period | |
env: | |
HYPERSYNC_API_KEY: ${{ secrets.HYPERSYNC_API_KEY }} | |
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }} | |
run: | | |
yarn ts-node scripts/uploadCurrentPeriodKpis.ts \ | |
--calculation-timestamp ${{ github.event.inputs.timestamp }} \ | |
--protocols ${{ github.event.inputs.protocols }} \ | |
--redis-connection ${{ secrets.REDIS_CONNECTION }} | |
- name: Notify Slack on Failure | |
if: ${{ failure() || cancelled() }} | |
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 | |
with: | |
webhook: ${{ secrets.SLACK_ON_CALL_WEBHOOK_URL }} | |
webhook-type: incoming-webhook | |
payload: | | |
text: "⚠️ <!subteam^S0277QUM4KB> Periodic KPI calculation and upload workflow failed! The next scheduled run will automatically backfill any missed data, so single failures are generally not a concern. If failures continue, please review the run details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |