Theme Action to hook for one time only function [duplicate]

There is no such thing as “theme activation”. Using the customizer you can change settings for any theme on the server, whether it is “active” or not, but at that context the theme will be active and if your code will not work correctly in that context users might be upset.

If you need to build a DB for your theme, just store a version indication, and use one of the available hooks to perform DB upgrade when there is a version mismatch between what the current version expect to find, and what is actually there. But be careful, judging from your other question, you want to create front end posts, and that should be done only when the user specifically initiates the action.