chore(ci): publish to GH Pages

This commit is contained in:
Fernando Falci 2024-04-22 15:58:17 +02:00
parent ac6095e2b2
commit ca1defd3a8
No known key found for this signature in database
GPG Key ID: AB787B833D90361D
5 changed files with 122 additions and 8 deletions

57
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: Deploy static content to Pages
on:
push:
branches: ['main']
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install deps
run: yarn
- name: Build
run: yarn build
- name: CNAME
run: cp ./CNAME ./dist
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

@ -1,8 +1,67 @@
# React + Vite
# Wallet.id
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
This is a white label template for [hns.id](https://hns.id). You can fork and modify to be used with any staked TLD
Currently, two official plugins are available:
## Customization
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
Basic customization are in the [`constants.js`](./src/constants.js) file and the [`src/assets`](./src/assets/) folder, more specifically `avatar.png` and `brand.png`, as well as `public/favicon.svg`.
For more advanced customization, any component can be updated.
## Contracts
The contracts addresses are also in the [constants.js](/src/constants.js#L17-L23) file. First is the testnet (Optimism Sepolia), and second the mainnet (Optimism).
## Data
This project can be deployed as static website. All the data needed comes from smart contracts.
Handling the communication with the contracts can be done with 2 React hooks:
### useDomainStatus()
```jsx
const { data } = useDomainStatus({ label: 'my-sld' });
/* Returns:
{
"isAvailable": true,
"labelValid": true,
"publicRegistrationOpen": false,
"isPremium": false,
"priceInDollars": "5.00",
"priceInWei": "2500000000000000",
"label": "my-sld"
}
/*
```
### useRegister()
```jsx
const register = useRegister({
label: 'my-sld',
priceInWei: '2500000000000000',
});
<button onClick={register}>🤝</button>;
```
`register` is an async function that will invoke Metamask (or any other wallet the user choose) and will be resolved once the user signs the transaction.
## Running locally
It uses yarn, so...
```
yarn install
yarn dev
```
... should do the magic.
## GitHub Pages
As mentioned about, this project can be deployed as a static webpage, with no need for a backend like NodeJS or even Vercel, making it a great fit for GitHub pages.
After forking the project, enable **Pages** in the repository settings and update the [`CNAME`](./CNAME) file.

View File

@ -1 +0,0 @@
wallet.id

View File

@ -1 +0,0 @@
wallet.id

View File

@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build --outDir docs",
"build": "vite build --outDir dist",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},