Daily Balance Snapshots #84
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: Daily Balance Snapshots | |
| # This workflow takes daily snapshots of wallet balances and stores them in the database. | |
| # API requests require SNAPSHOT_AUTH_TOKEN secret to be set in GitHub repository settings. | |
| on: | |
| schedule: | |
| # Run at midnight UTC every day | |
| - cron: '0 0 * * *' | |
| # Allow manual triggering for testing | |
| workflow_dispatch: | |
| jobs: | |
| snapshot-balances: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 300 # 5 hours timeout (GitHub Actions max is 6 hours) | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install script dependencies | |
| run: | | |
| cd scripts | |
| npm install | |
| - name: Run batch snapshot orchestration | |
| run: | | |
| cd scripts | |
| npm start | |
| env: | |
| API_BASE_URL: "https://multisig.meshjs.dev" | |
| SNAPSHOT_AUTH_TOKEN: ${{ secrets.SNAPSHOT_AUTH_TOKEN }} | |
| BATCH_SIZE: 5 | |
| DELAY_BETWEEN_BATCHES: 10 | |
| MAX_RETRIES: 3 | |
| REQUEST_TIMEOUT: 45 | |
| ENABLE_WARM_UP: true | |
| - name: Notify on failure | |
| if: failure() | |
| # Send failure notification | |
| run: | | |
| echo "❌ Daily balance snapshot job failed" | |
| if [ -n "${{ secrets.SNAPSHOT_ERROR_DISCORD_WEBHOOK_URL }}" ]; then | |
| curl -X POST -H 'Content-type: application/json' \ | |
| --data "{\"content\":\"❌ Daily balance snapshots failed. Check the GitHub Actions logs.\"}" \ | |
| ${{ secrets.SNAPSHOT_ERROR_DISCORD_WEBHOOK_URL }} || echo "Failed to send Discord notification" | |
| else | |
| echo "SNAPSHOT_ERROR_DISCORD_WEBHOOK_URL not configured, skipping notification" | |
| fi |