Several possible answers depending on several different situations of which you have not apprised us. Simplest but perhaps not the best would be a float-operated valve similar in operation to a toilet tank fill valve.