From 63b1d6cc16cd928362fb753b6936d80bf5f2fb2c Mon Sep 17 00:00:00 2001 From: Daniil Suvorov Date: Wed, 6 Sep 2023 10:51:36 +0300 Subject: [PATCH] =?UTF-8?q?fix(VKUI=20patch):=20getBooleanInput=20fix=20re?= =?UTF-8?q?quired=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20get?= =?UTF-8?q?BooleanInput=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=B7=20`@actions/core`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://github.com/actions/toolkit/issues/844 --- VKUI/patch/src/getBooleanInput.ts | 22 ++++++++++++++++++++++ VKUI/patch/src/main.ts | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 VKUI/patch/src/getBooleanInput.ts diff --git a/VKUI/patch/src/getBooleanInput.ts b/VKUI/patch/src/getBooleanInput.ts new file mode 100644 index 00000000..ab120512 --- /dev/null +++ b/VKUI/patch/src/getBooleanInput.ts @@ -0,0 +1,22 @@ +import * as core from '@actions/core'; + +const trueValue = ['true', 'True', 'TRUE']; +const falseValue = ['false', 'False', 'FALSE']; + +/** + * Исправленная версия getBooleanInput функции из `@actions/core`. + * + * [getBooleanInput ignores options.required](https://github.com/actions/toolkit/issues/844) + */ +export function getBooleanInput(name: string, options?: core.InputOptions): boolean { + const val = core.getInput(name, options); + + if (!val) return false; + if (trueValue.includes(val)) return true; + if (falseValue.includes(val)) return false; + + throw new TypeError( + `Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + + `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``, + ); +} diff --git a/VKUI/patch/src/main.ts b/VKUI/patch/src/main.ts index 87c05221..89e3ac27 100644 --- a/VKUI/patch/src/main.ts +++ b/VKUI/patch/src/main.ts @@ -7,6 +7,7 @@ import { SemVer } from 'semver'; import { getPatchInstructions } from './message'; import { getMergeData } from './getMergeData'; import { stableBranchName } from './stableBranchName'; +import { getBooleanInput } from './getBooleanInput'; function getPrNumber() { const pullRequest = github.context.payload.pull_request; @@ -49,7 +50,7 @@ async function run(): Promise { const token = core.getInput('token', { required: true }); const directory = core.getInput('directory'); const targetBranchInput = core.getInput('targetBranch'); - const needScreenshots = core.getBooleanInput('needScreenshots'); + const needScreenshots = getBooleanInput('needScreenshots'); const pullNumber = getPrNumber(); const gh = github.getOctokit(token);