You can do something like this.
add_action('publish_page', 'bt_publish_post', 10, 2);
function bt_publish_post ($post_id, $post) {
// our bt_page_status codes will indicate one of three thing
// if empty than we know that page is published
// if 1 we know that page was updated for the first time
// if 2 we know that page was updated for the second and so on time (2,3,4 stc... times)
$bt_page_status = get_post_meta($post_id, 'bt_page_status', true);
if (empty($bt_page_status)) {
// page is published
// do some code here
// now we set bt_page_status to 1 so next time we know that page is being updated for the first time
update_post_meta($post_id, 'bt_page_status', 1);
} elseif ($bt_page_status == 1) {
// page is updated for the first time
// do some code here
// now we set bt_page_status to 2 so next time we know that page is being updated for the second and so on time
update_post_meta($post_id, 'bt_page_status', 2);
} elseif ($bt_page_status == 2) {
// page is updated for the second and so on time
// do some code here
// if you need more checks you can continue adding them accordingly
}
}
This will trigger when page is being created or updated while in the publish status.
If you need to run code on other statuses with other conditions let me know =]