-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (80 loc) · 3.25 KB
/
Copy pathcron-update-data.yml
File metadata and controls
94 lines (80 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: "Cron: Update Data"
on:
schedule:
- cron: "0 0 */3 * *" # Runs every 3 days at midnight UTC
workflow_dispatch: # Allows manual triggering
jobs:
update-price-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