Skip to content

Update Price Data

Update Price Data #3

name: "Update Price Data"
on:
schedule:
- cron: "0 0 */3 * *" # Runs every 3 days at midnight UTC
workflow_dispatch: # Allows manual triggering
jobs:
update-data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up devkit
uses: sablier-labs/devkit/actions/setup@main
with:
package-manager: bun
- name: Install qsv
uses: cargo-bins/cargo-binstall@main
- name: Install qsv binary
run: cargo binstall --no-confirm qsv
- name: Fetch cryptocurrency prices
env:
COINGECKO_API_KEY_1: ${{ secrets.COINGECKO_API_KEY_1 }}
COINGECKO_API_KEY_2: ${{ secrets.COINGECKO_API_KEY_2 }}
run: just fetch-crypto 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@v2
with:
app-id: ${{ vars.APP_ID }}
owner: ${{ github.repository_owner }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
repositories: price-data,indexers,accounting
- 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