Beaching a leaking ship (if loaded with cargo) (i. e. voluntary stranding) to prevent her foundering will generally be allowed as general average, as this is intentional and voluntary.
Costs of repairs to the damage causing the leak, if caused by an insured peril, would qualify in particular average, not general average. Refloating an accidentally grounded ship could be a general average act, since the act of refloating is intentional.