Structucturing my .gitlab-ci.yml file for CI

Hi, total n00b here. I’m trying to figure out the best way to structure my .gitlab-ci.yml file to deploy my code on a runner. If I am working on a project where I’m required to either compile a program by source or edit a number of config files, what’s the best way to approach this? Also, how would the Git runner know when my code is successfully executed without any issue and is there a way to define parameters for a successful execution in the event the runner somehow keeps going and doesn’t stop?