Skip to content

Calculate and Upload KPIs #3397

Calculate and Upload KPIs

Calculate and Upload KPIs #3397

name: Calculate and Upload KPIs
on:
schedule:
- cron: '0 */3 * * *' # Runs at minute 0 every 3 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
project_id: divvi-production
credentials_json: ${{ secrets.DIVVI_PRODUCTION_UPLOADER_SERVICE_ACCOUNT_KEY }}
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.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 }}
PROSPERITY_PASSPORT_API_KEY: ${{ secrets.PROSPERITY_PASSPORT_API_KEY }}
GOOGLE_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
CAMPAIGN_SETTINGS_GOOGLE_SHEET_ID: ${{ secrets.CAMPAIGN_SETTINGS_GOOGLE_SHEET_ID }}
run: |
yarn ts-node scripts/uploadCurrentPeriodKpis.ts \
--calculation-timestamp ${{ github.event.inputs.timestamp }} \
--protocols ${{ github.event.inputs.protocols }} \
--redis-connection ${{ secrets.REDIS_CONNECTION }} \
--kpi-function-id ${{ github.sha }}
- 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 }}"