Skip to content

Commit

Permalink
fix: Fix pr_number being null when triggered by issue_comment (#272)
Browse files Browse the repository at this point in the history
* fix: Fix `pr_number` when triggered by `issue_comment`

* default to `0` if `context.issue.number` is absent

Big thanks to @p4perf4ce for contributing.

---------

Co-authored-by: Rishav Dhar <19497993+RDhar@users.noreply.github.com>
  • Loading branch information
p4perf4ce and rdhar authored Aug 9, 2024
1 parent 8dda305 commit 6104dec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ module.exports = async ({ context, core, exec, github }) => {
const fmt_result_limit = 6e3;

// Get PR number from event trigger for unique identifier.
let pr_number = 0;
if (context.eventName === "pull_request") {
pr_number = context.issue.number;
} else if (context.eventName === "push") {
let pr_number;
if (context.eventName === "push") {
const { data: list_prs_of_commit } =
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
Expand All @@ -22,6 +20,8 @@ module.exports = async ({ context, core, exec, github }) => {
pr_number = pr.number;
} else if (context.eventName === "merge_group") {
pr_number = parseInt(context.ref.split("/pr-")[1]);
} else {
pr_number = context.issue.number || 0;
}

// Check for Tofu CLI path.
Expand Down

0 comments on commit 6104dec

Please sign in to comment.