@@ -50,10 +50,9 @@ async function triggerGithub(strapi: Core.Strapi) {
5050}
5151
5252export default {
53- register ( /* { strapi }: { strapi: Core.Strapi } */ ) { } ,
53+ register ( ) { } ,
5454
5555 bootstrap ( { strapi } : { strapi : Core . Strapi } ) {
56- // Debug das envs na subida
5756 strapi . log . info ( '🔍 ENV DEBUG' , {
5857 GITHUB_OWNER : process . env . GITHUB_OWNER ,
5958 GITHUB_REPO : process . env . GITHUB_REPO ,
@@ -67,23 +66,27 @@ export default {
6766 strapi . db . lifecycles . subscribe ( {
6867 models : [ 'api::show.show' ] ,
6968
69+ // 👉 Não dispara nada na criação, só loga
7070 async afterCreate ( event ) {
71+ const { result } = event ;
7172 strapi . log . info (
72- ' [lifecycles global] afterCreate(show) chamado, disparando triggerGithub()'
73+ ` [lifecycles global] afterCreate(show) id= ${ result ?. id } publishedAt= ${ result ?. publishedAt } `
7374 ) ;
74- await triggerGithub ( strapi ) ;
7575 } ,
7676
77+ // 👉 Só dispara quando o registro ESTÁ publicado
7778 async afterUpdate ( event ) {
7879 const { result } = event ;
7980
81+ const isPublished = ! ! result ?. publishedAt ;
82+
8083 strapi . log . info (
81- `[lifecycles global] afterUpdate(show) chamado ( id=${ result ?. id } , publishedAt =${ result ?. publishedAt } ) `
84+ `[lifecycles global] afterUpdate(show) id=${ result ?. id } isPublished =${ isPublished } `
8285 ) ;
8386
84- if ( result ?. publishedAt ) {
87+ if ( isPublished ) {
8588 strapi . log . info (
86- '[lifecycles global] Registro publicado, disparando triggerGithub()'
89+ '[lifecycles global] Registro publicado/atualizado , disparando triggerGithub()'
8790 ) ;
8891 await triggerGithub ( strapi ) ;
8992 } else {
0 commit comments