name: Deploy to v4.stage.dydx.exchange

on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up pnpm
        uses: dydxprotocol/setup-pnpm@v1

      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: 18
          registry-url: https://registry.npmjs.org/
          cache: pnpm

      - name: Install dependencies
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: |
          pnpm install --loglevel warn

      - name: Build
        env:
          NODE_OPTIONS: '--max-old-space-size=4096'
        run: |
          pnpm run build --mode staging

      - name: Upload to IPFS via web3.storage
        uses: dydxprotocol/add-to-web3@v1
        id: web3storage
        with:
          web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }}
          path_to_add: 'dist'