diff --git a/action.yml b/action.yml index 041f612..cd9afb7 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,12 @@ inputs: description: >- The version of testdriverai to run. Defaults to "latest" required: false + create-pr: + type: boolean + description: >- + Specify if a PR should be created with the updated test results. Defaults to "false" + default: "false" + outputs: summary: description: >- diff --git a/dist/index.js b/dist/index.js index 2061b8b..9020925 100644 --- a/dist/index.js +++ b/dist/index.js @@ -33634,6 +33634,12 @@ const github = __nccwpck_require__(5438); class Config { constructor() { + const createPR = core.getInput("create-pr")?.toLowerCase()?.trim(); + if (!["true", "false"].includes(createPR)) { + throw new Error( + "Invalid value for create-pr input. It should be either true or false." + ); + } this.input = { prompt: core.getInput("prompt"), prerun: core.getInput("prerun"), @@ -33641,6 +33647,7 @@ class Config { key: core.getInput("key"), os: core.getInput("os") || "windows", version: core.getInput("version") || "latest", + createPR: JSON.parse(createPR), }; // the values of github.context.repo.owner and github.context.repo.repo are taken from @@ -39993,6 +40000,7 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms)); let key = config.input.key; let os = config.input.os; let testdriveraiVersion = config.input.version; + let createPR = config.input.createPR; console.log(`testdriver@${pgkVersion}`); console.log(`testdriver-action@${testdriverBranch}`); @@ -40000,18 +40008,18 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms)); let prompt = process.env.IS_DEV ? "open youtube" : config.input.prompt.replace(/(\r\n|\n)/g, function (match) { - return match === "\n" ? "\\n" : "\\r\\n"; - }); - - console.log(""); - console.log(chalk.green('Inputs')); + return match === "\n" ? "\\n" : "\\r\\n"; + }); + + console.log(""); + console.log(chalk.green("Inputs")); console.log(chalk.yellow("repo:"), repo); console.log(chalk.yellow("branch:"), branch); console.log(chalk.yellow("os:"), os); console.log(chalk.yellow("prompt:")); - console.log(prompt.replace(/\\n/g, '\n').replace(/\\r\\n/g, '\r\n')); + console.log(prompt.replace(/\\n/g, "\n").replace(/\\r\\n/g, "\r\n")); console.log(chalk.yellow("prerun:")); - console.log(prerun.replace(/\\n/g, '\n').replace(/\\r\\n/g, '\r\n')); + console.log(prerun.replace(/\\n/g, "\n").replace(/\\r\\n/g, "\r\n")); console.log(""); console.log(chalk.green("TestDriver:"), '"Looking into it..."'); @@ -40036,6 +40044,7 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms)); os, personalAccessToken, testdriveraiVersion, + createPR, }, { Accept: "application/json", diff --git a/src/config.js b/src/config.js index f0c5d03..3062686 100644 --- a/src/config.js +++ b/src/config.js @@ -3,6 +3,12 @@ const github = require("@actions/github"); class Config { constructor() { + const createPR = core.getInput("create-pr")?.toLowerCase()?.trim(); + if (!["true", "false"].includes(createPR)) { + throw new Error( + "Invalid value for create-pr input. It should be either true or false." + ); + } this.input = { prompt: core.getInput("prompt"), prerun: core.getInput("prerun"), @@ -10,6 +16,7 @@ class Config { key: core.getInput("key"), os: core.getInput("os") || "windows", version: core.getInput("version") || "latest", + createPR: JSON.parse(createPR), }; // the values of github.context.repo.owner and github.context.repo.repo are taken from diff --git a/src/index.js b/src/index.js index 65325cb..3de78c3 100644 --- a/src/index.js +++ b/src/index.js @@ -35,6 +35,7 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms)); let key = config.input.key; let os = config.input.os; let testdriveraiVersion = config.input.version; + let createPR = config.input.createPR; console.log(`testdriver@${pgkVersion}`); console.log(`testdriver-action@${testdriverBranch}`); @@ -42,18 +43,18 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms)); let prompt = process.env.IS_DEV ? "open youtube" : config.input.prompt.replace(/(\r\n|\n)/g, function (match) { - return match === "\n" ? "\\n" : "\\r\\n"; - }); - - console.log(""); - console.log(chalk.green('Inputs')); + return match === "\n" ? "\\n" : "\\r\\n"; + }); + + console.log(""); + console.log(chalk.green("Inputs")); console.log(chalk.yellow("repo:"), repo); console.log(chalk.yellow("branch:"), branch); console.log(chalk.yellow("os:"), os); console.log(chalk.yellow("prompt:")); - console.log(prompt.replace(/\\n/g, '\n').replace(/\\r\\n/g, '\r\n')); + console.log(prompt.replace(/\\n/g, "\n").replace(/\\r\\n/g, "\r\n")); console.log(chalk.yellow("prerun:")); - console.log(prerun.replace(/\\n/g, '\n').replace(/\\r\\n/g, '\r\n')); + console.log(prerun.replace(/\\n/g, "\n").replace(/\\r\\n/g, "\r\n")); console.log(""); console.log(chalk.green("TestDriver:"), '"Looking into it..."'); @@ -78,6 +79,7 @@ const waitFor = (ms) => new Promise((r) => setTimeout(r, ms)); os, personalAccessToken, testdriveraiVersion, + createPR, }, { Accept: "application/json",