Skip to content

Commit ffa949e

Browse files
committed
Add IPFS preview deploy Github Action.
Fix IPFS action version. Switch to hash routing. Add actions to use Github Deployments API. Update IPFS action to use Web3.Storage. Fix start deployment step. Refactor deploy pipeline. Add ref to deployment. Add dev branch deploys. Fix deployment env reference. Fix env reference.
1 parent e183b03 commit ffa949e

File tree

4 files changed

+84
-31
lines changed

4 files changed

+84
-31
lines changed

.github/workflows/github_action.yml

-28
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: IPFS Preview Deploy - Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
cleanup:
9+
name: Remove test environment deployment
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Inject slug variables
13+
uses: rlespinasse/[email protected]
14+
15+
- name: Mark deployment as deactivated
16+
uses: bobheadxi/[email protected]
17+
with:
18+
step: deactivate-env
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}

.github/workflows/preview-deploy.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: IPFS Preview Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
develop-ci:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [14.x]
16+
steps:
17+
- name: Inject slug variables
18+
uses: rlespinasse/[email protected]
19+
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
28+
- name: Start Deployment
29+
uses: bobheadxi/[email protected]
30+
id: deployment
31+
with:
32+
step: start
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}
35+
ref: ${{ github.head_ref }}
36+
37+
- name: Remove dependencies
38+
run: rm -rf package-lock.json node_modules
39+
40+
- name: Install dependencies
41+
run: npm install
42+
43+
- name: Build Dapp
44+
run: npm run build:xdai
45+
46+
- name: Deploy to IPFS
47+
uses: web3-storage/add-to-web3@v1
48+
id: web3
49+
with:
50+
web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }}
51+
path_to_add: 'build'
52+
53+
- name: Update Deployment Status
54+
uses: bobheadxi/[email protected]
55+
if: always()
56+
with:
57+
step: finish
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
status: ${{ job.status }}
60+
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
61+
env_url: 'https://${{ steps.web3.outputs.cid }}.ipfs.dweb.link'

src/App.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client'
44
import React, { Suspense, useEffect, useState, useCallback } from 'react'
55
import styled, { ThemeProvider } from 'styled-components'
66
import { ToastContainer } from 'react-toastify'
7-
import { BrowserRouter } from 'react-router-dom'
7+
import { HashRouter } from 'react-router-dom'
88
import { useWeb3React } from '@web3-react/core'
99
import { CookiesProvider } from 'react-cookie'
1010
import Axios from 'axios'
@@ -84,7 +84,7 @@ export const App = () => {
8484
<ThemeProvider theme={theme}>
8585
<GlobalStyle />
8686
<Suspense fallback={<Center minHeight="100vh">LOADING</Center>}>
87-
<BrowserRouter>
87+
<HashRouter>
8888
<Container>
8989
<Header />
9090
<AppRouter />
@@ -109,7 +109,7 @@ export const App = () => {
109109
/>
110110
{!isMobile && <FeedbackOverlay />}
111111
</Container>
112-
</BrowserRouter>
112+
</HashRouter>
113113
</Suspense>
114114
</ThemeProvider>
115115
</SanctionContext.Provider>

0 commit comments

Comments
 (0)