Skip to content

feat: optimize tick liquidity fetching through indexer #1129

feat: optimize tick liquidity fetching through indexer

feat: optimize tick liquidity fetching through indexer #1129

Workflow file for this run

name: Deploy Preview
on:
pull_request:
branches: [main]
types: [opened, synchronize, labeled]
jobs:
build_preview:
# require 'deploy preview' label
# but do not run if already labeled with 'deploy preview' and a different label was just added
# eg. a PR that already has a preview has the label "released" applied by semantic release bot
if: (!github.event.label && contains(github.event.pull_request.labels.*.name, 'deploy preview')) || github.event.label.name == 'deploy preview'
runs-on: ubuntu-latest
steps:
- name: Checkout branch head (not merged head)
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set Deploy Preview alias name (combine short SHA and files hash) (deploy alias max length is 37)
run: |
SHORT_SHA=$(node -p "'${{ github.event.pull_request.head.sha }}'.slice(0,8)")
SHORT_HASH=$(node -p "'${{ env.all-files-hash }}'.slice(0,8)")
echo "::set-output name=DEPLOY_PREVIEW_ALIAS::$SHORT_SHA-$SHORT_HASH"
env:
all-files-hash: ${{ hashFiles('**/*') }}
id: get-deploy-alias
- name: Set Node version
# use basic regex (first found digits and dots) to get Node engine version from package.json
# will fail if not correctly specified
run: |
NODE_VERSION=$(node -p "require('./package.json').engines.node.match(/[\d.]+/)[0]")
echo "::set-output name=NODE_VERSION::$NODE_VERSION"
id: get-node-version
- name: Use Node.js ${{ steps.get-node-version.outputs.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ steps.get-node-version.outputs.NODE_VERSION }}
- name: Add deployment preview specific environment variables
run: cp .env.deploy-previews .env.local
- name: Install dependencies
run: npm ci
- name: Build
run: PUBLIC_URL=https://${{ env.deploy-alias }}--duality-xyz.netlify.app npm run build
env:
deploy-alias: ${{ steps.get-deploy-alias.outputs.DEPLOY_PREVIEW_ALIAS }}
- name: Deploy preview to Netlify
id: netlify_deploy
# see: https://github.com/marketplace/actions/netlify-deploy
uses: jsmrcaga/action-netlify-deploy@v1.7.2
with:
# secret tokens are added in Github project settings under [project]/settings/secrets/actions
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_DEPLOY_MESSAGE: Preview deploy ${{ github.ref }} # github.ref looks like `refs/pull/[PR#]/merge`
NETLIFY_DEPLOY_TO_PROD: false
deploy_alias: ${{ steps.get-deploy-alias.outputs.DEPLOY_PREVIEW_ALIAS }}
build_directory: build
# we skip the build steps in this custom step because if we allow the project to build inside this step
# and specify the node version for that, this action will first download the latest node version,
# then switch back to the specified node version, then build the project.
# this wastes build minutes, so we instead pre-build the "build" folder
build_command: echo "already built app"
install_command: echo "already installed dependencies"
- name: Add comment to PR
if: github.ref != 'refs/heads/main' #github.ref looks like `refs/pull/[PR#]/merge`
env:
# secret tokens are added in Github project settings under [project]/settings/secrets/actions
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# get deploy outputs: see https://github.com/marketplace/actions/netlify-deploy#outputs
# get PR number: see https://github.com/actions/checkout/issues/58#issuecomment-812259610
run: |
echo "Preview URL: ${{ steps.netlify_deploy.outputs.NETLIFY_PREVIEW_URL }}" > netlify.txt
echo "Logs: ${{ steps.netlify_deploy.outputs.NETLIFY_LOGS_URL }}" >> netlify.txt
gh pr comment ${{ github.event.pull_request.number }} --body-file netlify.txt || true