From 3fdee343c8e7b0403b03d568b9983a0fc5a5ac86 Mon Sep 17 00:00:00 2001 From: Kun Date: Mon, 29 Mar 2021 17:34:04 +0800 Subject: [PATCH] [CD] Deploy dotapps.io(IPFS version) more decentralized with Crust (#4933) * Fix abnormal account type * Fix crust logo invisible * Add Crust Rococo V1 Endpoint * Upgrade to Crust Maxwell * Apply crust type package and add DCF provider * Change ipfs upload in a more decentralized way * Add CRUST_SEEDS env variable --- .github/workflows/push-master.yml | 1 + package.json | 1 + scripts/ipfsUpload.cjs | 6 ++++++ yarn.lock | 13 ++++++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 0e38f76bfefe..c7f5bc4ff714 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -21,6 +21,7 @@ jobs: env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} + CRUST_SEEDS: ${{ secrets.CRUST_SEEDS }} GH_PAGES_SRC: packages/apps/build GH_PAT: ${{ secrets.GH_PAT }} GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }} diff --git a/package.json b/package.json index fcf88c243874..488ba1730961 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@babel/core": "^7.13.10", "@babel/register": "^7.13.8", "@babel/runtime": "^7.13.10", + "@crustio/crust-pin": "^0.0.1", "@pinata/sdk": "^1.1.13", "@polkadot/dev": "^0.62.7", "@polkadot/ts": "^0.3.62", diff --git a/scripts/ipfsUpload.cjs b/scripts/ipfsUpload.cjs index 1d7d15947898..fece220df8dd 100644 --- a/scripts/ipfsUpload.cjs +++ b/scripts/ipfsUpload.cjs @@ -3,6 +3,7 @@ const fs = require('fs'); const pinataSDK = require('@pinata/sdk'); +const crustPin = require('@crustio/crust-pin').default; const cloudflare = require('dnslink-cloudflare'); const execSync = require('@polkadot/dev/scripts/execSync.cjs'); @@ -19,6 +20,7 @@ const PINMETA = { name: DOMAIN }; const repo = `https://${process.env.GH_PAT}@github.com/${process.env.GITHUB_REPOSITORY}.git`; const pinata = pinataSDK(process.env.PINATA_API_KEY, process.env.PINATA_SECRET_KEY); +const crust = crustPin(process.env.CRUST_SEEDS); function writeFiles (name, content) { [DST, SRC].forEach((root) => @@ -36,6 +38,7 @@ skip-checks: true"`); } async function pin () { + // 1. Pin on pinata const result = await pinata.pinFromFS(DST, { pinataMetadata: PINMETA }); const url = `${GATEWAY}${result.IpfsHash}/`; const html = ` @@ -58,6 +61,9 @@ async function pin () { writeFiles('pin.json', JSON.stringify(result)); updateGh(result.IpfsHash); + // 2. Decentralized pin on Crust + await crust.pin(result.IpfsHash); + console.log(`Pinned ${result.IpfsHash}`); return result.IpfsHash; diff --git a/yarn.lock b/yarn.lock index ccd6b0be70fd..20dab7497a3b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1412,7 +1412,17 @@ __metadata: languageName: node linkType: hard -"@crustio/type-definitions@npm:0.0.5": +"@crustio/crust-pin@npm:^0.0.1": + version: 0.0.1 + resolution: "@crustio/crust-pin@npm:0.0.1" + dependencies: + "@crustio/type-definitions": ^0.0.5 + "@polkadot/api": ^3.11.1 + checksum: 036cec0b77385b1ed0d8fa3fb91e8921b998a994ef1f45983911b473be4bedf259ae56babb581466bad588670a574580ce38d15ceeba35686ee4cc56312bdc4d + languageName: node + linkType: hard + +"@crustio/type-definitions@npm:0.0.5, @crustio/type-definitions@npm:^0.0.5": version: 0.0.5 resolution: "@crustio/type-definitions@npm:0.0.5" dependencies: @@ -14559,6 +14569,7 @@ fsevents@~2.1.2: "@babel/core": ^7.13.10 "@babel/register": ^7.13.8 "@babel/runtime": ^7.13.10 + "@crustio/crust-pin": ^0.0.1 "@pinata/sdk": ^1.1.13 "@polkadot/dev": ^0.62.7 "@polkadot/ts": ^0.3.62