Skip to content

Commit

Permalink
fix: detect pull-requests correctly (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez authored Jul 7, 2022
1 parent 71b1e39 commit 7edd063
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7513,11 +7513,11 @@ var import_core2 = __toESM(require_core(), 1);
var import_github = __toESM(require_github(), 1);
import process2 from "process";
var getPrNumber = () => {
const { eventName, payload } = import_github.context;
const { eventName, payload, workflow_run: workflowRun } = import_github.context;
if (eventName === "pull_request") {
return payload.number;
}
if (eventName === "workflow_run" && payload?.workflow_run?.pull_requests?.length === 1) {
if (eventName === "workflow_run" && workflowRun?.event === "pull_request" && payload?.workflow_run?.pull_requests?.length === 1) {
return payload.workflow_run.pull_requests[0].number;
}
};
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/lib/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import core from '@actions/core'
import { context } from '@actions/github'

const getPrNumber = () => {
const { eventName, payload } = context
const { eventName, payload, workflow_run: workflowRun } = context

if (eventName === 'pull_request') {
return payload.number
}

if (eventName === 'workflow_run' && payload?.workflow_run?.pull_requests?.length === 1) {
if (
eventName === 'workflow_run' &&
workflowRun?.event === 'pull_request' &&
payload?.workflow_run?.pull_requests?.length === 1
) {
return payload.workflow_run.pull_requests[0].number
}
}
Expand Down

0 comments on commit 7edd063

Please sign in to comment.