11import * as core from '@actions/core'
22import * as github from '@actions/github'
33import { createOrUpdateComment , renderComment } from './comment'
4- import { renderPlan } from './render'
4+ import { planIsEmpty , renderPlan } from './render'
55
66async function run ( ) {
77 // 1) Setup
@@ -10,7 +10,8 @@ async function run() {
1010 planfile : core . getInput ( 'planfile' , { required : true } ) ,
1111 terraformCmd : core . getInput ( 'terraform-cmd' , { required : true } ) ,
1212 workingDirectory : core . getInput ( 'working-directory' , { required : true } ) ,
13- header : core . getInput ( 'header' , { required : true } )
13+ header : core . getInput ( 'header' , { required : true } ) ,
14+ skipEmpty : core . getBooleanInput ( 'skip-empty' , { required : true } )
1415 }
1516 const octokit = github . getOctokit ( inputs . token )
1617
@@ -24,10 +25,12 @@ async function run() {
2425 )
2526
2627 // 3) Post comment
27- await core . group ( 'Render comment' , ( ) => {
28- const comment = renderComment ( { plan, header : inputs . header } )
29- return createOrUpdateComment ( { octokit, content : comment } )
30- } )
28+ if ( ! inputs . skipEmpty || ! planIsEmpty ( plan ) ) {
29+ await core . group ( 'Render comment' , ( ) => {
30+ const comment = renderComment ( { plan, header : inputs . header } )
31+ return createOrUpdateComment ( { octokit, content : comment } )
32+ } )
33+ }
3134}
3235
3336async function main ( ) {
0 commit comments