Cron: Update Data #308
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: "Cron: Update Data" | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # Runs every day at midnight UTC | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| update-price-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: sablier-labs/devkit/actions/setup@v1 | |
| with: | |
| package-manager: bun | |
| - name: Install qsv | |
| run: | | |
| wget -O - https://dathere.github.io/qsv-deb-releases/qsv-deb.gpg | sudo gpg --dearmor -o /usr/share/keyrings/qsv-deb.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/qsv-deb.gpg] https://dathere.github.io/qsv-deb-releases ./" | sudo tee /etc/apt/sources.list.d/qsv.list | |
| sudo apt update | |
| sudo apt install qsv | |
| - name: Fetch cryptocurrency prices | |
| env: | |
| COINGECKO_API_KEY: ${{ secrets.COINGECKO_API_KEY }} | |
| run: just fetch-crypto-recent --currency all | |
| - name: Fetch forex rates | |
| env: | |
| CURRENCY_FREAKS_API_KEY: ${{ secrets.CURRENCY_FREAKS_API_KEY }} | |
| run: just fetch-forex | |
| - name: Validate TSV files | |
| run: just tsv-check | |
| - name: Verify changes | |
| run: | # shell | |
| if ! git diff --quiet -- crypto/ forex/; then | |
| echo "✅ TSV files were updated" | |
| exit 0 | |
| else | |
| echo "❌ No TSV files were updated - API fetch may have failed" | |
| exit 1 | |
| fi | |
| - name: Get app installation token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| client-id: ${{ vars.UPDATER_APP_CLIENT_ID }} | |
| owner: ${{ github.repository_owner }} | |
| private-key: ${{ secrets.UPDATER_APP_PRIVATE_KEY }} | |
| repositories: price-data,indexers,accounting | |
| permission-contents: write | |
| - name: Generate timestamp | |
| id: timestamp | |
| run: echo "human=$(date '+%B %d, %Y at %H:%M UTC')" >> $GITHUB_OUTPUT | |
| - name: Commit and push changes | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | # shell | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git | |
| git add crypto/ forex/ | |
| git commit -m "chore: update price data - ${{ steps.timestamp.outputs.human }}" | |
| git push | |
| - name: Trigger downstream updates | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | # shell | |
| gh api repos/sablier-labs/indexers/dispatches \ | |
| -f event_type=price-data-updated \ | |
| -f client_payload[timestamp]="${{ steps.timestamp.outputs.human }}" | |
| gh api repos/sablier-labs/accounting/dispatches \ | |
| -f event_type=price-data-updated \ | |
| -f client_payload[timestamp]="${{ steps.timestamp.outputs.human }}" | |
| - name: Add summary | |
| run: | # shell | |
| echo "## Update result" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Passed" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Updated price data at ${{ steps.timestamp.outputs.human }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Triggered updates in:" >> $GITHUB_STEP_SUMMARY | |
| echo "- sablier-labs/indexers" >> $GITHUB_STEP_SUMMARY | |
| echo "- sablier-labs/accounting" >> $GITHUB_STEP_SUMMARY |