-
Notifications
You must be signed in to change notification settings - Fork 40
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
Showing
5 changed files
with
109 additions
and
2 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,54 @@ | ||
name: Chaindata Publish | ||
|
||
on: | ||
# runs on each commit pushed to the `main` branch | ||
push: | ||
branches: [main] | ||
# runs at `0 minutes past the hour, every 6 hours`, starting at midnight UTC | ||
schedule: | ||
- cron: '0 0/6 * * *' | ||
# can be run manually from the `Actions` tab | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
# only run 1 job per branch/pr/etc at a time | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
jobs: | ||
publish: | ||
name: 'Collate & publish chaindata to GitHub Pages' | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v3 | ||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
- name: Install dependencies | ||
run: yarn --immutable | ||
- name: Collate chaindata | ||
run: node scripts/publish.js | ||
- name: Upload pages artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
path: 'dist' | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Talisman Chaindata CI | ||
name: Chaindata Validate | ||
|
||
on: | ||
push: | ||
|
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 |
---|---|---|
|
@@ -20,3 +20,5 @@ yarn-debug.log* | |
yarn-error.log* | ||
.pnpm-debug.log* | ||
yarn-error.log* | ||
|
||
dist |
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
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,50 @@ | ||
import fs from 'fs' | ||
|
||
// Can be used for nicer vscode syntax highlighting & auto formatting | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#raw_strings | ||
const html = (strings, ...values) => String.raw({ raw: strings }, ...values) | ||
|
||
const chaindata = JSON.parse(fs.readFileSync('chaindata.json')) | ||
|
||
const filesList = [] | ||
|
||
fs.rmSync('dist', { recursive: true, force: true }) | ||
fs.mkdirSync('dist') | ||
|
||
filesList.push('chaindata.json') | ||
fs.writeFileSync('dist/chaindata.json', JSON.stringify(chaindata, null, 2)) | ||
|
||
fs.mkdirSync('dist/chains/byId', { recursive: true }) | ||
for (const chain of chaindata) { | ||
if (!Array.isArray(chain.rpcs) || chain.rpcs.length < 1) continue | ||
|
||
if (typeof chain.id !== 'string') continue | ||
filesList.push(`chains/byId/${chain.id}.json`) | ||
fs.writeFileSync( | ||
`dist/chains/byId/${chain.id}.json`, | ||
JSON.stringify(chain, null, 2) | ||
) | ||
} | ||
|
||
fs.writeFileSync( | ||
'dist/index.html', | ||
html`<html> | ||
<head> | ||
<meta name="color-scheme" content="light dark" /> | ||
<style> | ||
html { | ||
font-family: sans-serif; | ||
} | ||
a { | ||
text-decoration: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<pre style="word-wrap: break-word; white-space: pre-wrap;"> | ||
<h3>Chaindata</h3> | ||
${filesList.map((file) => html`<a href="${file}">${file}</a>`).join('\n')} | ||
</pre> | ||
</body> | ||
</html>` | ||
) |