Skip to content

Update Supply from Tokenomics API #19

Update Supply from Tokenomics API

Update Supply from Tokenomics API #19

Workflow file for this run

name: Update Supply from Tokenomics API
on:
schedule:
# Run every day at 6 AM UTC
- cron: '0 6 * * *'
# workflow_dispatch:
jobs:
update-json:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Call API and extract data
run: |
# Create v1 directory if it doesn't exist
mkdir -p ./v1
# Call the API and save the response
if ! curl -sS -L -f "https://api.andromedaprotocol.io/v1/tokenomics/history?limit=1" -o response.json; then
echo "Failed to fetch data from API"
exit 1
fi
# Extract circulating supply from the API response using jq
if ! jq -e '.result[0].circulating_supply' response.json > ./v1/circulating_supply.json; then
echo "Failed to extract circulating supply from response"
exit 1
fi
# Clean up temporary file
rm response.json
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if ! git diff --quiet ./v1/circulating_supply.json; then
git add ./v1/circulating_supply.json
git commit -m 'Automated update of JSON file with circulating supply from API'
if ! git push; then
echo "Failed to push changes"
exit 1
fi
else
echo "No changes to circulating supply to commit."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}