From de3825ec26443311d93c849a90666dc2a8a1efc8 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-prod.yml | 60 +++++++++++++ .github/workflows/explorer-deploy-staging.yml | 87 +++++++++++++++++++ .github/workflows/releaser.yml | 1 - .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 +- 9 files changed, 220 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/explorer-build.yml create mode 100644 .github/workflows/explorer-deploy-prod.yml create mode 100644 .github/workflows/explorer-deploy-staging.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-prod.yml b/.github/workflows/explorer-deploy-prod.yml new file mode 100644 index 00000000..a41c6ddc --- /dev/null +++ b/.github/workflows/explorer-deploy-prod.yml @@ -0,0 +1,60 @@ +name: Deploy explorer + +on: + workflow_dispatch: + +jobs: + deploy-explorer-prod: + 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: 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=dist --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/explorer-deploy-staging.yml b/.github/workflows/explorer-deploy-staging.yml new file mode 100644 index 00000000..4cd49a8b --- /dev/null +++ b/.github/workflows/explorer-deploy-staging.yml @@ -0,0 +1,87 @@ +name: Deploy explorer + +on: + pull_request: + branches: + - dev + push: + branches: + - dev + +jobs: + deploy-explorer-staging: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: explorer + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - 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 + + - name: Deploy explorer to Netlify + if: steps.check-changes.outputs.changed == 'true' + uses: netlify/actions/cli@master + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_STAGING }} + with: + args: deploy --dir=dist --alias=deploy-preview-${{ github.event.number }} + + - 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/releaser.yml b/.github/workflows/releaser.yml index 633d2aae..59008e75 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -1,4 +1,3 @@ ---- name: New version releaser on: 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 }}