-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
890ce94
commit eb6b623
Showing
3 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Get full info | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-24.04 | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22' | ||
|
||
- name: Install dependencies | ||
run: npm install tsx | ||
|
||
- name: Generate | ||
run: npx tsx .github/workflows/scripts/extract-metadata.ts | ||
|
||
- name: Release latest full info | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: latest | ||
tag_name: latest | ||
files: full-info.json | ||
fail_on_unmatched_files: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import fs from 'fs/promises'; | ||
import path from 'path'; | ||
import { pathToFileURL } from 'url'; | ||
|
||
type Info = Partial<{ | ||
name: string; | ||
description: string; | ||
tags: string[]; | ||
cmcId: string; | ||
links: [ | ||
{ | ||
type: string; | ||
name: string; | ||
url: string; | ||
}, | ||
{ | ||
type: string; | ||
name: string; | ||
url: string; | ||
}, | ||
{ | ||
type: string; | ||
name: string; | ||
url: string; | ||
} | ||
]; | ||
}>; | ||
|
||
type Entity = { | ||
info: Info; | ||
logo: string; | ||
}; | ||
|
||
enum DIRECTORIES { | ||
VAULTS = 'vaults', | ||
TOKENS = 'tokens', | ||
NETWORKS = 'networks', | ||
OPERATORS = 'operators', | ||
POINTS = 'points', | ||
} | ||
|
||
type Template = Record<DIRECTORIES, Record<string, Entity>>; | ||
|
||
async function grabEntitiesInfo(globalDirs: DIRECTORIES[]) { | ||
const result = Object.values(DIRECTORIES).reduce<Template>((acc, curr) => { | ||
acc[curr] = {}; | ||
return acc; | ||
}, {} as Template); | ||
|
||
for (const dir of globalDirs) { | ||
try { | ||
const subdirs = await fs.readdir(dir); | ||
for (const subdir of subdirs) { | ||
const entityPath = path.join(dir, subdir); | ||
try { | ||
const infoPath = path.join(entityPath, 'info.json'); | ||
const infoUrl = pathToFileURL(infoPath).href; | ||
|
||
const module = await import(infoUrl); | ||
const info: Info = module.default; | ||
result[dir as DIRECTORIES][subdir] = { | ||
info, | ||
logo: | ||
'https://raw.githubusercontent.com/symbioticfi/metadata-mainnet/main/' + | ||
entityPath + | ||
'/logo.png', | ||
}; | ||
} catch (error) { | ||
console.error('Error processing entity in ' + entityPath, error); | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Error reading directory ' + dir, error); | ||
} | ||
} | ||
|
||
const filePath = path.join(process.cwd(), 'full-info.json'); | ||
await fs.writeFile(filePath, JSON.stringify(result, null, '\t'), 'utf8'); | ||
} | ||
|
||
grabEntitiesInfo(Object.values(DIRECTORIES)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Validate Pull Request | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
validate-pr: | ||
runs-on: ubuntu-24.04 | ||
timeout-minutes: 5 | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
|
||
- name: Detect changed files | ||
uses: yumemi-inc/changed-files@v3 | ||
id: changes | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
|
||
- name: Validate | ||
uses: symbioticfi/metadata-validation-scripts@main | ||
with: | ||
files: ${{ steps.changes.outputs.files }} | ||
issue: ${{ github.event.number }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
chain-id: 1 | ||
network-registry: "0xc773b1011461e7314cf05f97d95aa8e92c1fd8aa" | ||
operator-registry: "0xad817a6bc954f678451a71363f04150fdd81af9f" | ||
vault-registry: "0xaeb6bdd95c502390db8f52c8909f703e9af6a346" |