From d31d58f1845d6b1ab4da03283ed5a5a4e8a62445 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Thu, 19 Dec 2024 10:23:06 +0000 Subject: [PATCH 1/2] adding check for no issue number --- .github/workflows/reusable_terraform_plan_apply.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/reusable_terraform_plan_apply.yml b/.github/workflows/reusable_terraform_plan_apply.yml index 7e5a4191f..ee90d2dcd 100644 --- a/.github/workflows/reusable_terraform_plan_apply.yml +++ b/.github/workflows/reusable_terraform_plan_apply.yml @@ -126,6 +126,10 @@ jobs: const identifier = workflowId ? `_${workflowId}_\n` : `_${{ inputs.workflow_id }}_\n`; const summary = `\`${{ steps.show.outputs.summary }}\``; const issue_number = context.payload.pull_request.number; + if (!issue_number) { + console.log('No issue number found, skipping comment.'); + return; + } await github.rest.issues.createComment({ ...context.repo, issue_number, From ed57fe029af02147039f0881a0d389af3b780e89 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Thu, 19 Dec 2024 15:25:46 +0000 Subject: [PATCH 2/2] added another check to validate the if statment --- .github/workflows/reusable_terraform_plan_apply.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_terraform_plan_apply.yml b/.github/workflows/reusable_terraform_plan_apply.yml index ee90d2dcd..7cc46160d 100644 --- a/.github/workflows/reusable_terraform_plan_apply.yml +++ b/.github/workflows/reusable_terraform_plan_apply.yml @@ -125,7 +125,7 @@ jobs: const workflowId = "${{ env.WORKSPACE_NAME }}"; const identifier = workflowId ? `_${workflowId}_\n` : `_${{ inputs.workflow_id }}_\n`; const summary = `\`${{ steps.show.outputs.summary }}\``; - const issue_number = context.payload.pull_request.number; + const issue_number = context.payload.pull_request ? context.payload.pull_request.number : null; if (!issue_number) { console.log('No issue number found, skipping comment.'); return;