how to check if a block is there and if so emit a redstone signal in Minecraft 1.12.2 vanilla

Read about the "testforblock" command: https://www.digminecraft.com/game_commands/testforblock_command.php

You can have the command block say /testforblock <x> <y> <z> <block>

Heres an example: /testforblock ~ ~-1 ~ diamond_ore

The /testforblock command works in 1.12.2

To have it continuously check, set it to repeat.

To detect when it has found the block, you can have a comparator running out from the command block.