From 9af0b14c5e305183906731dc9609811e2d527081 Mon Sep 17 00:00:00 2001 From: sophian Date: Mon, 12 Aug 2024 15:07:16 -0400 Subject: [PATCH 1/6] Migrate files and add build script --- .github/workflows/publish_to_ipfs.yml | 35 +++++++------------------ build.js | 15 +++++++++++ data-dev.json => metadata/data-dev.json | 0 data.json => metadata/data.json | 0 package.json | 15 +++++++++++ 5 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 build.js rename data-dev.json => metadata/data-dev.json (100%) rename data.json => metadata/data.json (100%) create mode 100644 package.json diff --git a/.github/workflows/publish_to_ipfs.yml b/.github/workflows/publish_to_ipfs.yml index c107819..338ff7c 100644 --- a/.github/workflows/publish_to_ipfs.yml +++ b/.github/workflows/publish_to_ipfs.yml @@ -12,28 +12,6 @@ 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/ipfs-action@v0.1.5 - 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: runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' @@ -43,12 +21,17 @@ jobs: - 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/ipfs-action@v0.1.5 with: - path: ./out/pools.json + path: ./out/prime.json service: pinata pinataPinName: mainnet-pools-$GITHUB_SHA pinataKey: ${{ secrets.PINATA_KEY }} @@ -77,6 +60,6 @@ jobs: 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 diff --git a/build.js b/build.js new file mode 100644 index 0000000..ef5f012 --- /dev/null +++ b/build.js @@ -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; + } + } +); diff --git a/data-dev.json b/metadata/data-dev.json similarity index 100% rename from data-dev.json rename to metadata/data-dev.json diff --git a/data.json b/metadata/data.json similarity index 100% rename from data.json rename to metadata/data.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..3f6d0a6 --- /dev/null +++ b/package.json @@ -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": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" +} From 587f129444337e67b86199918d04efd57d6a77d6 Mon Sep 17 00:00:00 2001 From: sophian Date: Mon, 12 Aug 2024 15:08:37 -0400 Subject: [PATCH 2/6] Remove main branch condition on workflow --- .github/workflows/publish_to_ipfs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish_to_ipfs.yml b/.github/workflows/publish_to_ipfs.yml index 338ff7c..d663962 100644 --- a/.github/workflows/publish_to_ipfs.yml +++ b/.github/workflows/publish_to_ipfs.yml @@ -14,7 +14,6 @@ permissions: jobs: release: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v2 From 58b9e686df85b2583306ea96921ebcee8a8b8dd1 Mon Sep 17 00:00:00 2001 From: sophian Date: Mon, 12 Aug 2024 15:32:49 -0400 Subject: [PATCH 3/6] publish initial prod copy --- .github/workflows/publish_to_ipfs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_to_ipfs.yml b/.github/workflows/publish_to_ipfs.yml index d663962..153a56d 100644 --- a/.github/workflows/publish_to_ipfs.yml +++ b/.github/workflows/publish_to_ipfs.yml @@ -24,7 +24,7 @@ jobs: if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then npm run prepublish else - npm run prepublish:dev + npm run prepublish fi - name: Upload to IPFS id: upload_to_ipfs @@ -40,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' id: create_release uses: actions/create-release@v1 env: @@ -53,6 +54,7 @@ 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: From d150c55ef60bfbbd6e6e8448728112186744716f Mon Sep 17 00:00:00 2001 From: sophian Date: Mon, 12 Aug 2024 15:38:00 -0400 Subject: [PATCH 4/6] Revert prod deployment --- .github/workflows/publish_to_ipfs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_to_ipfs.yml b/.github/workflows/publish_to_ipfs.yml index 153a56d..42fb69a 100644 --- a/.github/workflows/publish_to_ipfs.yml +++ b/.github/workflows/publish_to_ipfs.yml @@ -12,7 +12,7 @@ permissions: contents: write jobs: - release: + publish: runs-on: ubuntu-latest steps: @@ -22,7 +22,7 @@ jobs: node-version: 12.x - run: | if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - npm run prepublish + npm run prepublish:dev else npm run prepublish fi @@ -40,7 +40,7 @@ jobs: run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Create Release - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' # only create github release on main branch id: create_release uses: actions/create-release@v1 env: From 8aaafa8c1737b7619840801b3e11784cec86d23c Mon Sep 17 00:00:00 2001 From: sophian Date: Mon, 12 Aug 2024 15:48:43 -0400 Subject: [PATCH 5/6] Fix dev logic --- .github/workflows/publish_to_ipfs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_to_ipfs.yml b/.github/workflows/publish_to_ipfs.yml index 42fb69a..866d994 100644 --- a/.github/workflows/publish_to_ipfs.yml +++ b/.github/workflows/publish_to_ipfs.yml @@ -22,9 +22,9 @@ jobs: node-version: 12.x - run: | if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - npm run prepublish:dev - else npm run prepublish + else + npm run prepublish:dev fi - name: Upload to IPFS id: upload_to_ipfs From 2bdf4dfe4308edce09cb43b281e0caf581bcf3e2 Mon Sep 17 00:00:00 2001 From: sophian Date: Mon, 12 Aug 2024 15:56:31 -0400 Subject: [PATCH 6/6] Add README --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 89e7ff1..3f60049 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # Prime data -Repository for data related to Centrifuge Prime users. \ No newline at end of file +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).