name: V3 fork gates

on:
  pull_request:
    paths:
      - "v3-src/**"
      - "ci/fork-gates.sh"
      - ".github/workflows/v3-fork-gates.yml"
  push:
    branches:
      - fix/v3-base-fork
  workflow_dispatch:
    inputs:
      require_fork_rpcs:
        description: "Fail if any supported-chain RPC secret is unavailable"
        required: false
        default: false
        type: boolean

permissions:
  contents: read

jobs:
  foundry:
    runs-on: ubuntu-latest
    env:
      BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
      AVAX_RPC_URL: ${{ secrets.AVAX_RPC_URL }}
      ARB_RPC_URL: ${{ secrets.ARB_RPC_URL }}
      POLYGON_RPC_URL: ${{ secrets.POLYGON_RPC_URL }}
      REQUIRE_FORK_RPCS: ${{ inputs.require_fork_rpcs && '1' || '0' }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - uses: foundry-rs/foundry-toolchain@v1
      - name: Run RPC-free and optional fork gates
        run: ci/fork-gates.sh
