@@ -27,31 +27,38 @@ jobs:
27
27
uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
28
28
with :
29
29
script : |
30
+ console.log(context);
31
+
30
32
let pr;
31
33
let workflowRun;
32
34
let isLabel = false;
33
35
switch (context.eventName) {
34
36
case "workflow_dispatch":
37
+ console.log("Workflow dispatch event");
35
38
pr = (await github.rest.pulls.get({
36
39
owner: context.repo.owner,
37
40
repo: context.repo.repo,
38
41
pull_number: +context.payload.inputs.pr,
39
42
})).data;
40
43
break;
41
44
case "pull_request_target":
45
+ console.log("Pull request target event");
42
46
pr = context.payload.pull_request;
43
47
break;
44
48
case "workflow_run":
49
+ console.log("Workflow run event");
45
50
workflowRun = context.payload.workflow_run;
46
51
pr = workflowRun.pull_requests[0];
47
52
if (pr) {
53
+ console.log("PR found in workflow run");
48
54
// Reload the PR to get the labels.
49
55
pr = (await github.rest.pulls.get({
50
56
owner: context.repo.owner,
51
57
repo: context.repo.repo,
52
58
pull_number: pr.number,
53
59
})).data;
54
60
} else {
61
+ console.log("PR not found in workflow run");
55
62
// PRs sent from forks do not get the pull_requests field set.
56
63
// https://github.com/orgs/community/discussions/25220
57
64
pr = (await github.rest.pulls.list({
@@ -67,12 +74,16 @@ jobs:
67
74
throw new Error("Could not find PR");
68
75
}
69
76
77
+ console.log(`Found PR ${pr.html_url}`);
78
+ console.log(pr);
79
+
70
80
if (!pr.labels.some((label) => label.name === "deploy-preview")) {
71
81
console.log(`PR ${pr.number} does not have the deploy-preview label`);
72
82
return null;
73
83
}
74
84
75
85
if (!workflowRun) {
86
+ console.log(`No workflow run found in event, searching for it with ${pr.head.sha}`);
76
87
try {
77
88
workflowRun = (await github.rest.actions.listWorkflowRuns({
78
89
owner: context.repo.owner,
92
103
}
93
104
94
105
console.log(`Found workflow run ${workflowRun.html_url}`)
106
+ console.log(workflowRun)
95
107
96
108
if (workflowRun.conclusion !== "success") {
97
109
console.log(`Workflow run did not succeed`);
0 commit comments