Sync ERC-8004 Events #1662
This file contains hidden or 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: Sync ERC-8004 Events | |
| on: | |
| schedule: | |
| # Run every 15 minutes — incremental sync takes seconds once seeded. | |
| - cron: "*/15 * * * *" | |
| workflow_dispatch: | |
| inputs: | |
| chain: | |
| description: "Sync a specific chain ID (leave empty for all mainnets)" | |
| required: false | |
| type: string | |
| include_testnets: | |
| description: "Include testnet chains" | |
| required: false | |
| type: boolean | |
| default: false | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_LOG: info | |
| HF_REPO: qntx/erc8004-events | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| concurrency: | |
| group: sync-events | |
| cancel-in-progress: false | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Cache release binary | |
| id: bin-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: target/release/erc8004-events | |
| key: ${{ runner.os }}-erc8004-events-${{ hashFiles('**/Cargo.lock', 'erc8004-events/src/**', 'erc8004/src/**') }} | |
| - name: Setup Rust | |
| if: steps.bin-cache.outputs.cache-hit != 'true' | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| if: steps.bin-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-cargo- | |
| - name: Build | |
| if: steps.bin-cache.outputs.cache-hit != 'true' | |
| run: cargo build --release -p erc8004-events | |
| - name: Install Git LFS | |
| run: | | |
| git lfs install | |
| git config --global lfs.concurrenttransfers 4 | |
| # Clone existing dataset (with cursors + parquet) for incremental sync. | |
| # The repository MUST be seeded with an initial full sync before this | |
| # workflow can operate efficiently. See README for instructions. | |
| - name: Clone HuggingFace dataset | |
| run: | | |
| GIT_LFS_SKIP_SMUDGE=0 git clone \ | |
| "https://x-access-token:${{ secrets.HF_TOKEN }}@huggingface.co/datasets/${HF_REPO}" \ | |
| hf-data || { | |
| echo "::warning::HF repo not found — creating empty dataset" | |
| mkdir -p hf-data | |
| cd hf-data | |
| git init | |
| git remote add origin "https://x-access-token:${{ secrets.HF_TOKEN }}@huggingface.co/datasets/${HF_REPO}" | |
| } | |
| - name: Sync events | |
| run: | | |
| ARGS="sync --data-dir hf-data" | |
| if [ -n "${{ inputs.chain }}" ]; then | |
| ARGS="$ARGS --chain ${{ inputs.chain }}" | |
| fi | |
| if [ "${{ inputs.include_testnets }}" = "true" ]; then | |
| ARGS="$ARGS --include-testnets" | |
| fi | |
| ./target/release/erc8004-events --config config.toml $ARGS | |
| - name: Push to HuggingFace | |
| run: | | |
| cd hf-data | |
| # Track parquet files with Git LFS | |
| if [ ! -f .gitattributes ]; then | |
| echo "*.parquet filter=lfs diff=lfs merge=lfs -text" > .gitattributes | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No new events — skipping push." | |
| else | |
| git commit -m "sync: $(date -u +%Y-%m-%dT%H:%M:%SZ)" | |
| git push origin main | |
| fi |