Skip to content

Commit 35e034c

Browse files
Merge pull request #1 from centrifuge/add-deployment-to-ipfs
Add IPFS deployment
2 parents e064308 + 2bdf4df commit 35e034c

6 files changed

Lines changed: 53 additions & 29 deletions

File tree

.github/workflows/publish_to_ipfs.yml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,25 @@ permissions:
1212
contents: write
1313

1414
jobs:
15-
# For non-main branches, only push to IPFS so we can test it
16-
push:
17-
runs-on: ubuntu-latest
18-
if: github.ref != 'refs/heads/main'
19-
20-
steps:
21-
- uses: actions/checkout@v2
22-
- uses: actions/setup-node@v1
23-
with:
24-
node-version: 12.x
25-
- run: npm run prepublish
26-
- name: Upload to IPFS
27-
id: upload_to_ipfs
28-
uses: aquiladev/ipfs-action@v0.1.5
29-
with:
30-
path: ./out/pools.json
31-
service: pinata
32-
pinataPinName: mainnet-pools-$GITHUB_SHA
33-
pinataKey: ${{ secrets.PINATA_KEY }}
34-
pinataSecret: ${{ secrets.PINATA_SECRET }}
35-
36-
# For the main branch, push to IPFS and create a release
37-
release:
15+
publish:
3816
runs-on: ubuntu-latest
39-
if: github.ref == 'refs/heads/main'
4017

4118
steps:
4219
- uses: actions/checkout@v2
4320
- uses: actions/setup-node@v1
4421
with:
4522
node-version: 12.x
46-
- run: npm run prepublish
23+
- run: |
24+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
25+
npm run prepublish
26+
else
27+
npm run prepublish:dev
28+
fi
4729
- name: Upload to IPFS
4830
id: upload_to_ipfs
4931
uses: aquiladev/ipfs-action@v0.1.5
5032
with:
51-
path: ./out/pools.json
33+
path: ./out/prime.json
5234
service: pinata
5335
pinataPinName: mainnet-pools-$GITHUB_SHA
5436
pinataKey: ${{ secrets.PINATA_KEY }}
@@ -58,6 +40,7 @@ jobs:
5840
run: |
5941
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
6042
- name: Create Release
43+
if: github.ref == 'refs/heads/main' # only create github release on main branch
6144
id: create_release
6245
uses: actions/create-release@v1
6346
env:
@@ -71,12 +54,13 @@ jobs:
7154
draft: false
7255
prerelease: false
7356
- name: Upload Release Asset
57+
if: github.ref == 'refs/heads/main'
7458
id: upload-release-asset
7559
uses: actions/upload-release-asset@v1
7660
env:
7761
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7862
with:
7963
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
80-
asset_path: ./out/pools.json
81-
asset_name: pools.json
64+
asset_path: ./out/prime.json
65+
asset_name: prime.json
8266
asset_content_type: application/json

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# Prime data
22

3-
Repository for data related to Centrifuge Prime users.
3+
Repository for data related to Centrifuge Prime users.
4+
5+
## Publishing to IPFS
6+
7+
### Dev
8+
9+
Opening a PR will trigger a deployment of the `dev-data.json` file to IPFS. The new hash can be found in the `Upload to IPFS` step in the [Publish action](https://github.com/centrifuge/prime-data/actions/workflows/publish_to_ipfs.yml).
10+
11+
### Prod
12+
13+
Merging PR to main will trigger a release of the `data.json` file to IPFS. The new hash can be found in the latest [Github release](https://github.com/centrifuge/prime-data/releases).

build.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const fs = require("fs");
2+
3+
const args = process.argv.slice(2);
4+
const IS_DEV = args[0];
5+
const primeUsers = require(`./metadata/data${IS_DEV ? "-dev" : ""}.json`);
6+
7+
fs.writeFile(
8+
__dirname + "/out/prime.json",
9+
JSON.stringify(primeUsers),
10+
(err) => {
11+
if (err) {
12+
throw err;
13+
}
14+
}
15+
);
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "prime-data",
3+
"version": "1.0.0",
4+
"description": "Repository for data related to Centrifuge Prime users.",
5+
"main": "out/index.js",
6+
"scripts": {
7+
"prepublish": "npm run build",
8+
"prepublish:dev": "npm run build:dev",
9+
"build:dev": "mkdir -p out/ && node build.js dev",
10+
"build": "mkdir -p out/ && node build.js"
11+
},
12+
"author": "",
13+
"license": "ISC",
14+
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
15+
}

0 commit comments

Comments
 (0)