|
| 1 | +"use strict"; |
| 2 | +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
| 3 | + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
| 4 | + return new (P || (P = Promise))(function (resolve, reject) { |
| 5 | + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 6 | + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 7 | + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
| 8 | + step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 9 | + }); |
| 10 | +}; |
| 11 | +var __importStar = (this && this.__importStar) || function (mod) { |
| 12 | + if (mod && mod.__esModule) return mod; |
| 13 | + var result = {}; |
| 14 | + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; |
| 15 | + result["default"] = mod; |
| 16 | + return result; |
| 17 | +}; |
| 18 | +var __importDefault = (this && this.__importDefault) || function (mod) { |
| 19 | + return (mod && mod.__esModule) ? mod : { "default": mod }; |
| 20 | +}; |
| 21 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 22 | +const core = __importStar(require("@actions/core")); |
| 23 | +const checkKeyword_1 = require("./checkKeyword"); |
| 24 | +const setIssueLabel_1 = require("./setIssueLabel"); |
| 25 | +const setIssueAssignee_1 = require("./setIssueAssignee"); |
| 26 | +const github_1 = __importDefault(require("@actions/github")); |
| 27 | +function run() { |
| 28 | + return __awaiter(this, void 0, void 0, function* () { |
| 29 | + const comment = github_1.default.context.payload.comment; |
| 30 | + if (!comment) { |
| 31 | + core.setFailed("Action can only be run on comments"); |
| 32 | + return; |
| 33 | + } |
| 34 | + console.log(`comment': ${comment}`); |
| 35 | + try { |
| 36 | + core.setOutput("labeled", false.toString()); |
| 37 | + core.setOutput("assigned", false.toString()); |
| 38 | + const keywords = JSON.parse(core.getInput("keywords", { required: true })); |
| 39 | + console.log(`keywords: ${keywords}`); |
| 40 | + const token = core.getInput("github-token"); |
| 41 | + const hasKeyword = checkKeyword_1.checkKeyword(keywords, comment.body); |
| 42 | + if (!hasKeyword) { |
| 43 | + console.log("Keyword not included in this issue comment"); |
| 44 | + return; |
| 45 | + } |
| 46 | + const labelsInput = core.getInput("labels"); |
| 47 | + const assigneesInput = core.getInput("assignees"); |
| 48 | + if (!labelsInput && !assigneesInput) { |
| 49 | + core.setFailed("labels or assignees input not found. Make sure your `.yml` file contains `labels` or `assignees`"); |
| 50 | + } |
| 51 | + if (labelsInput) { |
| 52 | + const labels = JSON.parse(labelsInput); |
| 53 | + console.log(labels); |
| 54 | + setIssueLabel_1.setIssueLabel(token, labels); |
| 55 | + core.setOutput("labeled", true.toString()); |
| 56 | + } |
| 57 | + if (assigneesInput) { |
| 58 | + const assignees = JSON.parse(assigneesInput); |
| 59 | + console.log(assignees); |
| 60 | + setIssueAssignee_1.setIssueAssignee(token, assignees); |
| 61 | + core.setOutput("assigned", true.toString()); |
| 62 | + } |
| 63 | + } |
| 64 | + catch (error) { |
| 65 | + core.setFailed(error.message); |
| 66 | + } |
| 67 | + }); |
| 68 | +} |
| 69 | +run(); |
0 commit comments