Skip to content

Commit 2b152fa

Browse files
committed
Add some debugging prints
1 parent 4163cbf commit 2b152fa

File tree

3 files changed

+86
-62
lines changed

3 files changed

+86
-62
lines changed

dist/index.js

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28864,7 +28864,7 @@ function wrappy (fn, cb) {
2886428864

2886528865
/***/ }),
2886628866

28867-
/***/ 6442:
28867+
/***/ 1385:
2886828868
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
2886928869

2887028870
"use strict";
@@ -28893,32 +28893,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
2889328893
return result;
2889428894
};
2889528895
Object.defineProperty(exports, "__esModule", ({ value: true }));
28896+
exports.run = void 0;
2889628897
const core = __importStar(__nccwpck_require__(115));
2889728898
const github = __importStar(__nccwpck_require__(3007));
28898-
function doChecks() {
28899-
if (github.context.eventName === "pull_request") {
28900-
const pullPayload = github.context.payload;
28901-
const body = pullPayload.body;
28902-
core.info(`BODY IS: ${body}`);
28903-
if (!body) {
28904-
core.setFailed("No PR body provided. Please ensure you include the PR template.");
28905-
return 1;
28906-
}
28907-
const lower = body.toLowerCase();
28908-
const content = core.getInput("content").toLowerCase();
28909-
if (!lower.includes(content)) {
28910-
core.setFailed(`Content check for "${content}" was not successful.`);
28911-
return 1;
28899+
async function run() {
28900+
try {
28901+
if (github.context.eventName === "pull_request") {
28902+
core.debug(`CONTEXT IS: ${github.context}`);
28903+
core.debug(`PAYLOAD IS: ${github.context.payload}`);
28904+
const pullPayload = github.context.payload;
28905+
const body = pullPayload.body;
28906+
core.info(`BODY IS: ${body}`);
28907+
if (!body) {
28908+
core.setFailed("No PR body provided. Please ensure you include the PR template.");
28909+
return 1;
28910+
}
28911+
const lower = body.toLowerCase();
28912+
const content = core.getInput("content").toLowerCase();
28913+
if (!lower.includes(content)) {
28914+
core.setFailed(`Content check for "${content}" was not successful.`);
28915+
return 1;
28916+
}
28917+
core.setOutput("passed", "All content checks were successful!");
2891228918
}
28913-
core.setOutput("passed", "All content checks were successful!");
28919+
}
28920+
catch (error) {
28921+
// Fail the workflow run if an error occurs
28922+
if (error instanceof Error)
28923+
core.setFailed(error.message);
2891428924
}
2891528925
}
28916-
try {
28917-
doChecks();
28918-
}
28919-
catch (error) {
28920-
core.setFailed(error.message);
28921-
}
28926+
exports.run = run;
2892228927

2892328928

2892428929
/***/ }),
@@ -30812,12 +30817,22 @@ module.exports = parseParams
3081230817
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
3081330818
/******/
3081430819
/************************************************************************/
30815-
/******/
30816-
/******/ // startup
30817-
/******/ // Load entry module and return exports
30818-
/******/ // This entry module is referenced by other modules so it can't be inlined
30819-
/******/ var __webpack_exports__ = __nccwpck_require__(6442);
30820-
/******/ module.exports = __webpack_exports__;
30821-
/******/
30820+
var __webpack_exports__ = {};
30821+
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
30822+
(() => {
30823+
"use strict";
30824+
var exports = __webpack_exports__;
30825+
30826+
Object.defineProperty(exports, "__esModule", ({ value: true }));
30827+
/**
30828+
* The entrypoint for the action.
30829+
*/
30830+
const main_1 = __nccwpck_require__(1385);
30831+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
30832+
(0, main_1.run)();
30833+
30834+
})();
30835+
30836+
module.exports = __webpack_exports__;
3082230837
/******/ })()
3082330838
;

index.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,7 @@
1-
import * as core from '@actions/core'
2-
import * as github from "@actions/github";
3-
import { PullRequest } from "@octokit/webhooks-types";
1+
/**
2+
* The entrypoint for the action.
3+
*/
4+
import { run } from './main'
45

5-
6-
function doChecks() {
7-
if (github.context.eventName === "pull_request") {
8-
const pullPayload = github.context.payload as PullRequest;
9-
const body: string | null = pullPayload.body;
10-
11-
core.info(`BODY IS: ${body}`);
12-
13-
if (!body) {
14-
core.setFailed("No PR body provided. Please ensure you include the PR template.");
15-
return 1;
16-
}
17-
18-
const lower: string = body.toLowerCase();
19-
const content: string = core.getInput("content").toLowerCase();
20-
21-
if (!lower.includes(content)) {
22-
core.setFailed(`Content check for "${content}" was not successful.`);
23-
return 1;
24-
}
25-
26-
core.setOutput("passed", "All content checks were successful!");
27-
}
28-
}
29-
30-
try {
31-
doChecks();
32-
} catch (error: any) {
33-
core.setFailed(error.message);
34-
}
6+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
7+
run()

main.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as core from '@actions/core'
2+
import * as github from "@actions/github";
3+
import { PullRequest } from "@octokit/webhooks-types";
4+
5+
6+
export async function run() {
7+
try {
8+
if (github.context.eventName === "pull_request") {
9+
core.debug(`CONTEXT IS: ${github.context}`);
10+
core.debug(`PAYLOAD IS: ${github.context.payload}`);
11+
12+
const pullPayload = github.context.payload as PullRequest;
13+
const body: string | null = pullPayload.body;
14+
15+
core.info(`BODY IS: ${body}`);
16+
17+
if (!body) {
18+
core.setFailed("No PR body provided. Please ensure you include the PR template.");
19+
return 1;
20+
}
21+
22+
const lower: string = body.toLowerCase();
23+
const content: string = core.getInput("content").toLowerCase();
24+
25+
if (!lower.includes(content)) {
26+
core.setFailed(`Content check for "${content}" was not successful.`);
27+
return 1;
28+
}
29+
30+
core.setOutput("passed", "All content checks were successful!");
31+
}
32+
} catch (error) {
33+
// Fail the workflow run if an error occurs
34+
if (error instanceof Error) core.setFailed(error.message)
35+
}
36+
}

0 commit comments

Comments
 (0)