OP's 1st (2nd) action is (is not) covariant/geometric, respectively. OP's 2nd action transforms with a boundary term under general coordinate transformations.
The reason for the GHY boundary term in the first place is explained e.g. in this Phys.SE post.
OP asks in a comment:
Why is GHY term needed? Isn't space infinite without a boundary?
When deriving ...