From 5294015dbbe99e8924eb3be73acf646ca6b3b8f5 Mon Sep 17 00:00:00 2001 From: Alain Nicolas Date: Wed, 3 Jan 2024 21:52:03 +0100 Subject: [PATCH] feat: Deploy the Explorer in production mode --- .github/workflows/explorer-build.yml | 61 ++++++++++++ .github/workflows/explorer-deploy-preview.yml | 98 +++++++++++++++++++ .github/workflows/explorer-deploy-prod.yml | 67 +++++++++++++ .github/workflows/releaser.yml | 5 +- .github/workflows/sdk.yml | 2 +- .github/workflows/smart-contracts.yml | 14 +-- .github/workflows/subgraph.yml | 2 +- .github/workflows/website-build.yml | 4 +- .github/workflows/website-deploy.yml | 2 +- explorer/README.md | 2 +- 10 files changed, 241 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/explorer-build.yml create mode 100644 .github/workflows/explorer-deploy-preview.yml create mode 100644 .github/workflows/explorer-deploy-prod.yml diff --git a/.github/workflows/explorer-build.yml b/.github/workflows/explorer-build.yml new file mode 100644 index 00000000..39fa1f23 --- /dev/null +++ b/.github/workflows/explorer-build.yml @@ -0,0 +1,61 @@ +name: Build explorer + +on: + pull_request: + branches: + - main + - dev + - release/* + push: + branches: + - main + - dev + - release/* + +jobs: + build-explorer: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: explorer + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Install Pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: pnpm + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm run build + + - name: Add build summary + run: | + echo "## Explorer build result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/explorer-deploy-preview.yml b/.github/workflows/explorer-deploy-preview.yml new file mode 100644 index 00000000..1ed52d36 --- /dev/null +++ b/.github/workflows/explorer-deploy-preview.yml @@ -0,0 +1,98 @@ +name: Deploy preview explorer + +on: + pull_request: + branches: + - dev + push: + branches: + - dev + +jobs: + deploy-explorer-preview: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: explorer + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - id: check-changes + run: | + if [ -n "$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '^explorer/')" ]; then + echo "::set-output name=changed::true" + else + echo "::set-output name=changed::false" + fi + + - name: Install Pnpm + if: steps.check-changes.outputs.changed == 'true' + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Install Node.js + if: steps.check-changes.outputs.changed == 'true' + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: pnpm + + - name: Get pnpm store directory + if: steps.check-changes.outputs.changed == 'true' + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + if: steps.check-changes.outputs.changed == 'true' + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + if: steps.check-changes.outputs.changed == 'true' + run: pnpm install --frozen-lockfile + + - name: Build + if: steps.check-changes.outputs.changed == 'true' + run: pnpm run build + env: + VITE_WALLETCONNECT_PROJECT_ID: ${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }} + VITE_INFURA_API_KEY: ${{ secrets.VITE_INFURA_API_KEY }} + + - name: Deploy to Netlify + if: steps.check-changes.outputs.changed == 'true' + uses: nwtgck/actions-netlify@v2.0 + with: + publish-dir: "./explorer/dist" + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: "Deploy from GitHub Actions" + enable-pull-request-comment: true + enable-commit-comment: true + overwrites-pull-request-comment: true + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_STAGING }} + timeout-minutes: 1 + + - name: Add explorer deployment summary + if: steps.check-changes.outputs.changed == 'true' + run: | + echo "## Explorer staging deployment result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + + - name: Add explorer deployment summary + if: steps.check-changes.outputs.changed == 'false' + run: | + echo "## Explorer staging deployment result" >> $GITHUB_STEP_SUMMARY + echo "✅ No change detected in the explorer" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/explorer-deploy-prod.yml b/.github/workflows/explorer-deploy-prod.yml new file mode 100644 index 00000000..20e55c16 --- /dev/null +++ b/.github/workflows/explorer-deploy-prod.yml @@ -0,0 +1,67 @@ +name: Deploy production explorer + +on: + workflow_dispatch: + +jobs: + deploy-explorer-prod: + if: + github.actor == 'alainncls' || github.actor == 'satyajeetkolhapure' || github.actor == 'orbmis' || + github.actor == '0xEillo' || github.actor == 'ars9' || github.actor == 'Solniechniy' + + runs-on: ubuntu-latest + + defaults: + run: + working-directory: explorer + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Install Pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: pnpm + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm run build + env: + VITE_WALLETCONNECT_PROJECT_ID: ${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }} + VITE_INFURA_API_KEY: ${{ secrets.VITE_INFURA_API_KEY }} + + - name: Deploy explorer to Netlify + uses: netlify/actions/cli@master + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + with: + args: deploy --dir=./explorer/dist --filter explorer --prod + + - name: Add explorer deployment summary + run: | + echo "## Explorer production deployment result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 633d2aae..a8e2ef57 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -1,4 +1,3 @@ ---- name: New version releaser on: @@ -7,8 +6,8 @@ on: jobs: release: if: - github.actor == 'alainncls' || github.actor == 'fdemiramon' || github.actor == 'satyajeetkolhapure' || - github.actor == 'orbmis' || github.actor == '0xEillo' + github.actor == 'alainncls' || github.actor == 'satyajeetkolhapure' || github.actor == 'orbmis' || + github.actor == '0xEillo' runs-on: ubuntu-latest diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml index 516824ce..3a335153 100644 --- a/.github/workflows/sdk.yml +++ b/.github/workflows/sdk.yml @@ -13,7 +13,7 @@ on: - release/* jobs: - test: + test-sdk: runs-on: ubuntu-latest defaults: diff --git a/.github/workflows/smart-contracts.yml b/.github/workflows/smart-contracts.yml index 6bdce6a2..0a96621c 100644 --- a/.github/workflows/smart-contracts.yml +++ b/.github/workflows/smart-contracts.yml @@ -16,7 +16,7 @@ env: FOUNDRY_PROFILE: ci jobs: - build: + build-contracts: runs-on: ubuntu-latest defaults: @@ -43,7 +43,7 @@ jobs: echo "## Build result" >> $GITHUB_STEP_SUMMARY echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - test-unit: + test-contracts: runs-on: ubuntu-latest defaults: @@ -53,7 +53,7 @@ jobs: env: FOUNDRY_FUZZ_RUNS: 1000 - needs: build + needs: build-contracts steps: - name: Check out the repo @@ -72,10 +72,10 @@ jobs: echo "## Unit tests result" >> $GITHUB_STEP_SUMMARY echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - coverage: + coverage-contracts: runs-on: ubuntu-latest - needs: build + needs: build-contracts steps: - name: Check out the repo @@ -111,14 +111,14 @@ jobs: echo "## Coverage result" >> $GITHUB_STEP_SUMMARY echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY - upgradeability: + upgradeability-contracts: runs-on: ubuntu-latest defaults: run: working-directory: contracts - needs: build + needs: build-contracts steps: - name: Check out the repo diff --git a/.github/workflows/subgraph.yml b/.github/workflows/subgraph.yml index 1a15f58e..b10c5b8b 100644 --- a/.github/workflows/subgraph.yml +++ b/.github/workflows/subgraph.yml @@ -13,7 +13,7 @@ on: - release/* jobs: - test: + test-subgraph: runs-on: ubuntu-latest defaults: diff --git a/.github/workflows/website-build.yml b/.github/workflows/website-build.yml index a4de6c61..ef459d04 100644 --- a/.github/workflows/website-build.yml +++ b/.github/workflows/website-build.yml @@ -13,7 +13,7 @@ on: - release/* jobs: - website-build: + build-website: runs-on: ubuntu-latest defaults: @@ -57,5 +57,5 @@ jobs: - name: Add build summary run: | - echo "## Website built result" >> $GITHUB_STEP_SUMMARY + echo "## Website build result" >> $GITHUB_STEP_SUMMARY echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml index 1f36530c..a8e232c8 100644 --- a/.github/workflows/website-deploy.yml +++ b/.github/workflows/website-deploy.yml @@ -16,7 +16,7 @@ concurrency: cancel-in-progress: true jobs: - website-deploy: + deploy-website: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} diff --git a/explorer/README.md b/explorer/README.md index 3a8ff52e..302a5707 100644 --- a/explorer/README.md +++ b/explorer/README.md @@ -1,6 +1,6 @@ # Verax Attestation Registry - Explorer -This package manages the explorer of Verax Attestation Registry, soon to be released. +This package manages the explorer of Verax Attestation Registry, hosted at [explorer.ver.ax](https://explorer.ver.ax). ## Getting Started