Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions scripts/ipfsUpload.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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) =>
Expand All @@ -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 = `<!DOCTYPE html>
Expand All @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down