name: Verify Non Matching

on:
  pull_request_target:
    branches: [master]
  push:
    branches: [master]

jobs:
  verify-non-matching:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}

      - name: Install packages
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential libssl-dev pkg-config git python3 python3-pip binutils-mips-linux-gnu python3-venv libpcre2-dev libpcre2-8-0

      - name: Get ROM
        run: wget -q -O baseroms/baserom.us.v77.z64 ${{secrets.ROMURL}}

      - name: Verify ROM
        run: if [[ $(echo "0cb115d8716dbbc2922fda38e533b9fe63bb9670 baseroms/baserom.us.v77.z64" | sha1sum -c --quiet -) = "" ]]; then echo "Signature OK"; else echo "Failed"; exit 1; fi

      - name: Make Setup
        run: make setup -j4

      - name: Make Extract
        run: make extract

      - name: Extract Assets
        run: make assets -j4

      - name: Verify NON_MATCHING
        run: make -j4 NON_MATCHING=1
