Add a new target for deploying to IPFS (#819)

* Add a new target for deploying to IPFS

* verbose command

* Try the github action
This commit is contained in:
Moody Salem 2020-05-20 16:10:26 -05:00 committed by GitHub
parent 425a23774d
commit 0b8d05b696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 6 deletions

33
.github/workflows/ipfs-deploy.yaml vendored Normal file

@ -0,0 +1,33 @@
on:
push:
branches:
- v2
name: Deploy to IPFS
jobs:
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12'
- run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn
- run: yarn ipfs-build
- name: Upload to IPFS
id: upload
uses: aquiladev/ipfs-action@v1
with:
path: build/

@ -1,6 +1,6 @@
{
"name": "uniswap",
"description": "Uniswap Protocol",
"description": "Uniswap Interface",
"version": "0.1.0",
"homepage": "https://uniswap.exchange",
"private": true,
@ -83,8 +83,9 @@
"typescript": "^3.8.3"
},
"scripts": {
"start": "cross-env REACT_APP_GIT_COMMIT_HASH=$(git show -s --format=%H) react-scripts start",
"start": "react-scripts start",
"build": "cross-env REACT_APP_GIT_COMMIT_HASH=$(git show -s --format=%H) react-scripts build",
"ipfs-build": "cross-env PUBLIC_URL=\".\" react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",

@ -28,7 +28,7 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" />
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

@ -1,5 +1,5 @@
import React, { Suspense } from 'react'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import { BrowserRouter, HashRouter, Route, Switch } from 'react-router-dom'
import styled from 'styled-components'
import GoogleAnalyticsReporter from '../components/analytics/GoogleAnalyticsReporter'
import Footer from '../components/Footer'
@ -67,10 +67,17 @@ const BackgroundGradient = styled.div`
}
`
let Router: React.ComponentType
if (process.env.PUBLIC_URL === '.') {
Router = HashRouter
} else {
Router = BrowserRouter
}
export default function App() {
return (
<Suspense fallback={null}>
<BrowserRouter>
<Router>
<Route component={GoogleAnalyticsReporter} />
<Route component={DarkModeQueryParamReader} />
<AppWrapper>
@ -96,7 +103,7 @@ export default function App() {
</BodyWrapper>
<BackgroundGradient />
</AppWrapper>
</BrowserRouter>
</Router>
<div id="popover-container" />
</Suspense>
)