From f6cd0ffa38be57382af7fb5515467a541d5b664f Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 22 Feb 2021 12:56:50 -0500 Subject: [PATCH 1/4] Testing for PRs --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4eddb54..42a3da7 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,9 @@ try { const default_value = core.getInput('default-value'); const tag_position = core.getInput('tag-position'); + const payload = JSON.stringify(github.context.payload, undefined, 2) + console.log(`The event payload: ${payload}`); + var issue_body = github.context.payload.issue.body; // Remove line breaks issue_body = issue_body.replace(/(\r\n|\n|\r)/gm, " "); @@ -24,7 +27,7 @@ try { value = body_words[i + 1]; // Handle Tables - if (value == "|" && (i + 2) < body_words.length){ + if (value == "|" && (i + 3) < body_words.length && body_words[i+3] == "|"){ value = body_words[i + 2]; } } @@ -32,7 +35,7 @@ try { value = body_words[i + 1]; // Handle Tables - if (value == "|" && (i + 2) < body_words.length){ + if (value == "|" && (i + 3) < body_words.length && body_words[i+3] == "|"){ value = body_words[i + 2]; } break; From de092375cea24ad1e19d95c298317295b2d4abf3 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 22 Feb 2021 12:57:33 -0500 Subject: [PATCH 2/4] Testing for PRs --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 42a3da7..bebe7ba 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ try { const payload = JSON.stringify(github.context.payload, undefined, 2) console.log(`The event payload: ${payload}`); + var issue_body = github.context.payload.issue.body; // Remove line breaks issue_body = issue_body.replace(/(\r\n|\n|\r)/gm, " "); From 9bf72ddbe8d3be3fbd54afe671189090a1b4eab2 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 22 Feb 2021 13:02:16 -0500 Subject: [PATCH 3/4] PR Support --- index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index bebe7ba..f0f37e6 100644 --- a/index.js +++ b/index.js @@ -8,11 +8,16 @@ try { const default_value = core.getInput('default-value'); const tag_position = core.getInput('tag-position'); - const payload = JSON.stringify(github.context.payload, undefined, 2) - console.log(`The event payload: ${payload}`); - - - var issue_body = github.context.payload.issue.body; + if ('issue' in github.context.payload){ + var issue_body = github.context.payload.issue.body; + } + else if ('pull_request' in github.context.payload){ + var issue_body = github.context.payload.pull_request.body; + } + else{ + core.exportVariable(env_variable, default_value); + return; + } // Remove line breaks issue_body = issue_body.replace(/(\r\n|\n|\r)/gm, " "); From f47c1008d87060738d4c6d33f1b2841cd0e072e5 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 22 Feb 2021 13:04:30 -0500 Subject: [PATCH 4/4] Cleaning up for release --- .github/workflows/example.yml | 2 +- index.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 76bf38c..1982302 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: Run Action - uses: TheBurchLog/body-env-tag-action@1.0 + uses: TheBurchLog/body-env-tag-action@3.0 with: tag: 'body-tag:' env-variable: 'MY_TAG' diff --git a/index.js b/index.js index f0f37e6..cc76123 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ try { const default_value = core.getInput('default-value'); const tag_position = core.getInput('tag-position'); + // Find the correct body obj if ('issue' in github.context.payload){ var issue_body = github.context.payload.issue.body; }