What is the correct way to append a noun to a action. For example
I think both the above means "I will do my best at writing". In the example above, the stem of a verb is a noun.
I think these will both be understood, but it's probably more natural to say 書くことを頑張ります, add the word こと after the verb to turn it into a noun. If Japanese people hear you saying カキをがんばります they might think you are talking about eating oysters or persimmons.
Are both particles acceptable?
Yes, you can find many examples of Japanese people using both of these:
But it's not really clear what you want to say.