Skip to content

Commit

Permalink
Merge pull request #1 from centrifuge/add-deployment-to-ipfs
Browse files Browse the repository at this point in the history
Add IPFS deployment
  • Loading branch information
sophialittlejohn authored Aug 12, 2024
2 parents e064308 + 2bdf4df commit 35e034c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 29 deletions.
40 changes: 12 additions & 28 deletions .github/workflows/publish_to_ipfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,25 @@ permissions:
contents: write

jobs:
# For non-main branches, only push to IPFS so we can test it
push:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm run prepublish
- name: Upload to IPFS
id: upload_to_ipfs
uses: aquiladev/[email protected]
with:
path: ./out/pools.json
service: pinata
pinataPinName: mainnet-pools-$GITHUB_SHA
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}

# For the main branch, push to IPFS and create a release
release:
publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm run prepublish
- run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
npm run prepublish
else
npm run prepublish:dev
fi
- name: Upload to IPFS
id: upload_to_ipfs
uses: aquiladev/[email protected]
with:
path: ./out/pools.json
path: ./out/prime.json
service: pinata
pinataPinName: mainnet-pools-$GITHUB_SHA
pinataKey: ${{ secrets.PINATA_KEY }}
Expand All @@ -58,6 +40,7 @@ jobs:
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Create Release
if: github.ref == 'refs/heads/main' # only create github release on main branch
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -71,12 +54,13 @@ jobs:
draft: false
prerelease: false
- name: Upload Release Asset
if: github.ref == 'refs/heads/main'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
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
asset_path: ./out/pools.json
asset_name: pools.json
asset_path: ./out/prime.json
asset_name: prime.json
asset_content_type: application/json
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Prime data

Repository for data related to Centrifuge Prime users.
Repository for data related to Centrifuge Prime users.

## Publishing to IPFS

### Dev

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).

### Prod

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).
15 changes: 15 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require("fs");

const args = process.argv.slice(2);
const IS_DEV = args[0];
const primeUsers = require(`./metadata/data${IS_DEV ? "-dev" : ""}.json`);

fs.writeFile(
__dirname + "/out/prime.json",
JSON.stringify(primeUsers),
(err) => {
if (err) {
throw err;
}
}
);
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "prime-data",
"version": "1.0.0",
"description": "Repository for data related to Centrifuge Prime users.",
"main": "out/index.js",
"scripts": {
"prepublish": "npm run build",
"prepublish:dev": "npm run build:dev",
"build:dev": "mkdir -p out/ && node build.js dev",
"build": "mkdir -p out/ && node build.js"
},
"author": "",
"license": "ISC",
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}

0 comments on commit 35e034c

Please sign in to comment.