Skip to content

fix: limit market order should set limit to current market price #1524

fix: limit market order should set limit to current market price

fix: limit market order should set limit to current market price #1524

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 }}
# it is important to remove the default token credentials from git in this step
# otherwise they will get in the way of fetching the private TradingView dependency
persist-credentials: false
- 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 }}
cache: npm
- name: Install dependencies
# note: from https://github.com/actions/setup-node/issues/49#issuecomment-1293249466
# security consideration:
# Skip post-install scripts here, as a malicious script could steal NODE_AUTH_TOKEN.
# use variable to read in the exact chart library dependency specified in package.json
run: |
TVC_LOCATION=$( node -p "require('./package.json').dependencies['charting_library'].replace('github:','github.com/')" );
npm install --ignore-scripts https://dib542:$TOKEN@$TVC_LOCATION
env:
# to install TradingView private dependency, private GitHub credentials are needed
# secret tokens are added in Github project settings under [project]/settings/secrets/actions
TOKEN: ${{ secrets.GH_TOKEN }}
# `npm rebuild` will run all those post-install scripts for us.
- name: Run post-install scripts
run: npm rebuild && npm run prepare --if-present
# run build with .env.testnet file (instead of .env.production)
# and add Netlify settings
- name: Build testnet
run: npm run build -- --mode testnet && cp netlify.toml build/netlify.toml
env:
REACT_APP__BUILD_NUMBER: ${{ github.run_id }}
- name: Deploy testnet preview to Netlify
id: netlify_deploy_testnet_preview
# 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_TESTNET_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"
- uses: chrnorm/deployment-action@v2
name: Create GitHub Preview deployment
id: deployment
with:
token: '${{ secrets.GIT_PAT }}'
environment-url: ${{ steps.netlify_deploy_testnet_preview.outputs.NETLIFY_PREVIEW_URL }}
environment: Preview
initial-status: success
- name: Clear build folder
run: rm -rf build
# run build with .env.beta file (instead of .env.production)
# and add Netlify settings
- name: Build beta
run: npm run build -- --mode beta && cp netlify.toml build/netlify.toml
env:
REACT_APP__BUILD_NUMBER: ${{ github.run_id }}
- name: Deploy beta preview to Netlify
id: netlify_deploy_beta_preview
# 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_BETA_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:
# use GitHub action token to post comment to PR
GITHUB_TOKEN: ${{ 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 "## Deploy Previews" > netlify.txt
echo "### Testnet" >> netlify.txt
echo "Preview URL: ${{ steps.netlify_deploy_testnet_preview.outputs.NETLIFY_PREVIEW_URL }}" >> netlify.txt
echo "Logs: ${{ steps.netlify_deploy_testnet_preview.outputs.NETLIFY_LOGS_URL }}" >> netlify.txt
echo "### Beta" >> netlify.txt
echo "Preview URL: ${{ steps.netlify_deploy_beta_preview.outputs.NETLIFY_PREVIEW_URL }}" >> netlify.txt
echo "Logs: ${{ steps.netlify_deploy_beta_preview.outputs.NETLIFY_LOGS_URL }}" >> netlify.txt
gh pr comment ${{ github.event.pull_request.number }} --body-file netlify.txt || true