Skip to content

Commit

Permalink
chore(ci): publish to GH Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Falci committed Apr 22, 2024
1 parent ac6095e commit ca1defd
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 8 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
69 changes: 64 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion docs/CNAME

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit ca1defd

Please sign in to comment.