Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
INFURA_KEY=xxx
ALCHEMY_KEY=xxx # For zkEVM
# Blockchain API Keys for token metadata fetching
INFURA_KEY=your_infura_key_here
ALCHEMY_KEY=your_alchemy_key_here # For zkEVM
COINGECKO_API_KEY=xxx

# GitHub Personal Access Token for creating PRs
GITHUB_TOKEN=ghp_your_github_token_here
113 changes: 113 additions & 0 deletions .github/workflows/tokenlist-fetch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Token List Fetch

on:
workflow_dispatch:
inputs:
source_url:
description: 'Source URL for token list'
required: false
default: 'https://raw.githubusercontent.com/burrbear-dev/default-lists/main/src/tokens/mainnet/defaultTokenList.json'
type: string
target_token_file:
description: 'Target token file path'
required: false
default: 'src/tokenlists/balancer/tokens/berachain.ts'
type: string
assets_dir:
description: 'Assets directory for logos'
required: false
default: 'src/assets/images/tokens'
type: string

jobs:
update-tokenlist:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

- name: Fetch token list
run: |
# Set environment variables for the script
export SOURCE_URL="${{ inputs.source_url }}"
export TARGET_TOKEN_FILE="${{ inputs.target_token_file }}"
export ASSETS_DIR="${{ inputs.assets_dir }}"

# Run the fetch script
npm run tokenlist:fetch
env:
NODE_ENV: production

- name: Generate token list
run: |
# Run the generate script
npm run generate
env:
NODE_ENV: production
INFURA_KEY: ${{ secrets.INFURA_KEY }}
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}

- name: Check for changes
id: check-changes
run: |
if git diff --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected"
fi

- name: Create PR
if: steps.check-changes.outputs.changes == 'true'
run: |
# Set environment variables for the PR script
export TARGET_TOKEN_FILE="${{ inputs.target_token_file }}"
export ASSETS_DIR="${{ inputs.assets_dir }}"

# Run the PR creation script
npm run tokenlist:pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on PR
if: steps.check-changes.outputs.changes == 'true'
uses: actions/github-script@v7
with:
script: |
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${context.payload.ref || 'feat/tokenlist-update-' + new Date().toISOString().slice(0, 19).replace(/[:.]/g, '-')}`
});

if (pulls.length > 0) {
const pr = pulls[0];
const commentBody = '🤖 **Automated Token List Update**\n\nThis PR was automatically generated by the GitHub Actions workflow.\n\n**Workflow Details:**\n- **Triggered by**: Manual workflow dispatch\n- **Run ID**: [' + context.runId + '](' + context.serverUrl + '/' + context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + context.runId + ')\n- **Commit**: ' + context.sha + '\n\n**Changes:**\n- Updated token list with latest addresses\n- Downloaded new logo assets\n- Generated timestamped backups and logs\n\n---\n*This is an automated PR. Please review the changes before merging.*';

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: commentBody
});
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ dist
.DS_Store
.env
.idea/**

# Log files generated by scripts
fetch-tokenlist-*.log
create-pr-*.log
*.log
Loading
Loading