Custom field not updating via functions upon publishing

There are two problems that I can see that cause your code to fail.

The first is that you’re using update_page_meta, which does not exist. Use update_post_meta instead.

The second is that you’re using the action save_page, which also does not exist. Use save_post, save_post is an action triggered whenever a post or page is created or updated, so it is appropriate to use in your case.

For an overview of actions that you can use, see Action Reference