-
Notifications
You must be signed in to change notification settings - Fork 23
120 lines (117 loc) · 4.92 KB
/
release-frontend-build-ipfs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Release Frontend build to IPFS
on:
workflow_dispatch:
inputs:
require_unpin_previous_builds:
type: boolean
description: 'Unpin previous builds'
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
unpin_previous_builds:
name: Unpin Previous Builds
if: ${{ inputs.require_unpin_previous_builds }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies
run: yarn install
- name: Call Pinata API to unpin previous builds
uses: ./.github/workflows/pinata_unpin_content
with:
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}
upload_build:
name: Upload Frontend Build To IPFS
needs: unpin_previous_builds
runs-on: ubuntu-latest
outputs:
commit_short_hash: ${{ steps.commit.outputs.short }}
build_timestamp: ${{ steps.get_build_timestamp.outputs.build_timestamp }}
cidv0: ${{ steps.upload_frontend_build.outputs.hash }}
cidv1: ${{ steps.cidv0_to_cidv1.outputs.cidv1 }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- id: commit
uses: pr-mpt/actions-commit-hash@v2
- name: Setup Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install Dependencies
run: yarn install
- name: Set BUILD_TIMESTAMP
id: get_build_timestamp
run: echo "build_timestamp=$(date +%s)" >> "$GITHUB_OUTPUT"
- name: Build
run: REACT_APP_IPFS_BUILD=true yarn build
- name: Upload Frontend Build to IPFS via Pinata
id: upload_frontend_build
uses: aquiladev/ipfs-action@master
with:
path: apps/frontend/build
service: pinata
verbose: true
key: sovryn-dapp-frontend-build
pinName: Sovryn DAPP Frontend ${{ steps.commit.outputs.short }}
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}
- name: CIDv0 to CIDv1
id: cidv0_to_cidv1
uses: Uniswap/[email protected]
with:
cidv0: ${{ steps.upload_frontend_build.outputs.hash }}
pin_build_cidv1:
name: Pin Frontend Build CIDv1
needs: upload_build
runs-on: ubuntu-latest
steps:
- name: Call Pinate API to Pin Frontend Build CIDv1
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.pinata.cloud/pinning/pinByHash'
method: 'POST'
bearerToken: ${{ secrets.PINATA_JWT }}
customHeaders: '{"Content-Type": "application/json"}'
data: '{"hashToPin": "${{ needs.upload_build.outputs.cidv1 }}", "pinataMetadata": { "name": "Sovryn DAPP Frontend ${{ needs.upload_build.outputs.commit_short_hash }}"}}'
create_github_release:
name: Create Github Release
needs: upload_build
runs-on: ubuntu-latest
steps:
- name: Create GitHub Release with custom IPFS gateway
id: create_release_1
if: ${{ vars.IPFS_GATEWAY_URL }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.upload_build.outputs.commit_short_hash }}
release_name: Sovryn DAPP Frontend Release ${{ needs.upload_build.outputs.commit_short_hash }}
body: |
**Sovryn DAPP Mainnet gateways**:
- CIDv0: ${{ needs.upload_build.outputs.cidv0 }}
- CIDv1: ${{ needs.upload_build.outputs.cidv1 }}
- ${{ vars.IPFS_GATEWAY_URL }}/ipfs/${{ needs.upload_build.outputs.cidv1 }}
- https://cloudflare-ipfs.com/ipfs/${{ needs.upload_build.outputs.cidv1 }}
- https://ipfs.io/ipfs/${{ needs.upload_build.outputs.cidv1 }}
- https://${{ needs.upload_build.outputs.cidv1 }}.ipfs.dweb.link/
- [ipfs://${{ needs.upload_build.outputs.cidv1 }}/](ipfs://${{ needs.upload_build.outputs.cidv1 }}/)
- name: Create GitHub Release without custom IPFS gateway
id: create_release_2
if: ${{ !vars.IPFS_GATEWAY_URL }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.upload_build.outputs.commit_short_hash }}
release_name: Sovryn DAPP Frontend Release ${{ needs.upload_build.outputs.commit_short_hash }}
body: |
**Sovryn DAPP Mainnet gateways**:
- CIDv0: ${{ needs.upload_build.outputs.cidv0 }}
- CIDv1: ${{ needs.upload_build.outputs.cidv1 }}
- https://cloudflare-ipfs.com/ipfs/${{ needs.upload_build.outputs.cidv1 }}
- https://ipfs.io/ipfs/${{ needs.upload_build.outputs.cidv1 }}
- https://${{ needs.upload_build.outputs.cidv1 }}.ipfs.dweb.link/
- [ipfs://${{ needs.upload_build.outputs.cidv1 }}/](ipfs://${{ needs.upload_build.outputs.cidv1 }}/)