Israel and Lebanese militant group Hezbollah have agreed a ceasefire deal that will end more than a year of fighting.