Refresh R2 #968
This file contains 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: Refresh R2 | |
on: | |
schedule: | |
# ┌───── minute (0 - 59) | |
# │ ┌───── hour (0 - 23) | |
# │ │ ┌───── day of the month (1 - 31) | |
# │ │ │ ┌───── month (1 - 12) | |
# │ │ │ │ ┌───── day of the week (0 - 6) (Sunday to Saturday) | |
# │ │ │ │ │ | |
# │ │ │ │ │ | |
# │ │ │ │ │ | |
# * * * * * | |
- cron: '0 */2 * * *' # Every 3 hours | |
repository_dispatch: # REST API | |
types: | |
- 'refresh-r2' | |
workflow_dispatch: # Manual through GitHub UI | |
defaults: | |
run: | |
shell: bash | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
CLOUDFLARE_S3_URL: 'https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com' | |
jobs: | |
refresh-nft-collections: | |
name: 'DefiLlama NFT Collections' | |
runs-on: [ubuntu-latest] | |
timeout-minutes: 4 | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: '[Download] nft.llama.fi/collections' | |
run: | | |
curl --request GET \ | |
--silent \ | |
--show-error \ | |
--fail \ | |
--url 'https://nft.llama.fi/collections' \ | |
--header 'Accept: application/json' \ | |
--header 'Content-Type: application/json' \ | |
--output "/${{ runner.temp }}/llama_nft_collections.json" | |
- name: '[Upload] Cloudflare R2' | |
run: | | |
FILE_PATH="/${{ runner.temp }}/llama_nft_collections.json" \ | |
UPLOAD_PATH="nft/llama_nft_collections.json" \ | |
CLOUDFLARE_S3_URL="${{ env.CLOUDFLARE_S3_URL }}/llamafolio" \ | |
CLOUDFLARE_AWS_ACCESS_KEY_ID="${{ secrets.CLOUDFLARE_AWS_ACCESS_KEY_ID }}" \ | |
CLOUDFLARE_AWS_SECRET_ACCESS_KEY="${{ secrets.CLOUDFLARE_AWS_SECRET_ACCESS_KEY }}" \ | |
/bin/bash ${{ github.workspace }}/scripts/r2/upload.sh | |
refresh-nft-floors: | |
name: 'NFT Floors' | |
runs-on: [ubuntu-latest] | |
timeout-minutes: 4 | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: 'latest' | |
- name: '[Download] Floor Data' | |
env: | |
RESERVOIR_API_KEY: ${{ secrets.RESERVOIR_API_KEY }} | |
ELEMENT_API_KEY: ${{ secrets.ELEMENT_API_KEY }} | |
run: | | |
bun ./scripts/nft-floors.ts > "/${{ runner.temp }}/nft_floors.json" | |
- name: '[Upload] NFT Floors to Cloudflare R2' | |
run: | | |
FILE_PATH="/${{ runner.temp }}/nft_floors.json" \ | |
UPLOAD_PATH="nft/floors.json" \ | |
CLOUDFLARE_S3_URL="${{ env.CLOUDFLARE_S3_URL }}/llamafolio" \ | |
CLOUDFLARE_AWS_ACCESS_KEY_ID="${{ secrets.CLOUDFLARE_AWS_ACCESS_KEY_ID }}" \ | |
CLOUDFLARE_AWS_SECRET_ACCESS_KEY="${{ secrets.CLOUDFLARE_AWS_SECRET_ACCESS_KEY }}" \ | |
/bin/bash ${{ github.workspace }}/scripts/r2/upload.sh | |
refresh-yield-pools: | |
name: 'DefiLlama Yield Pools' | |
runs-on: [ubuntu-latest] | |
timeout-minutes: 4 | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: '[Download] yields.llama.fi/poolsOld' | |
run: | | |
curl --request GET \ | |
--silent \ | |
--show-error \ | |
--fail \ | |
--url 'https://yields.llama.fi/poolsOld' \ | |
--header 'Accept: application/json' \ | |
--header 'Content-Type: application/json' \ | |
--output "/${{ runner.temp }}/llama_yields_pools_old.json" | |
- name: '[Upload] Yield Pools to Cloudflare R2' | |
run: | | |
FILE_PATH="/${{ runner.temp }}/llama_yields_pools_old.json" \ | |
UPLOAD_PATH="yield/llama_yields_pools_old.json" \ | |
CLOUDFLARE_S3_URL="${{ env.CLOUDFLARE_S3_URL }}/llamafolio" \ | |
CLOUDFLARE_AWS_ACCESS_KEY_ID="${{ secrets.CLOUDFLARE_AWS_ACCESS_KEY_ID }}" \ | |
CLOUDFLARE_AWS_SECRET_ACCESS_KEY="${{ secrets.CLOUDFLARE_AWS_SECRET_ACCESS_KEY }}" \ | |
/bin/bash ${{ github.workspace }}/scripts/r2/upload.sh |