diff --git a/README.md b/README.md index 73cc8e8..432b41e 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,8 @@ inputs: required: true if_true: description: 'output value if cond is true' - required: true if_false: description: 'output value if cond is false' - required: true outputs: value: description: 'output value' diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index a0bf23c..38321af 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -24,3 +24,14 @@ test('test runs (false)', () => { } console.log(cp.execSync(`node ${ip}`, options).toString()) }) + +test('test runs (empty)', () => { + process.env['INPUT_COND'] = 'true' + process.env['INPUT_IF_TRUE'] = '' + process.env['INPUT_IF_FALSE'] = 'value-if-false' + const ip = path.join(__dirname, '..', 'lib', 'main.js') + const options: cp.ExecSyncOptions = { + env: process.env + } + console.log(cp.execSync(`node ${ip}`, options).toString()) +}) diff --git a/action.yml b/action.yml index 47b90db..7783e50 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: 'Conditional value for GitHub Action' -description: 'Conditional value for GitHub Action - missing expression for GitHub Actions' +name: 'Conditional value - missing expression for GitHub Actions' +description: 'Conditional value - missing expression for GitHub Actions' author: 'haya14busa' inputs: cond: @@ -7,10 +7,10 @@ inputs: required: true if_true: description: 'output value if cond is true' - required: true + default: '' if_false: description: 'output value if cond is false' - required: true + default: '' outputs: value: description: 'output value' diff --git a/dist/index.js b/dist/index.js index 3b298a0..efd68ef 100644 --- a/dist/index.js +++ b/dist/index.js @@ -77,8 +77,8 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const cond = core.getInput('cond', { required: true }); - const ifTrue = core.getInput('if_true', { required: true }); - const ifFalse = core.getInput('if_false', { required: true }); + const ifTrue = core.getInput('if_true'); + const ifFalse = core.getInput('if_false'); core.setOutput('value', cond === 'true' ? ifTrue : ifFalse); } catch (error) { diff --git a/src/main.ts b/src/main.ts index 88e0fbb..9aed827 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,8 +3,8 @@ import * as core from '@actions/core' async function run(): Promise { try { const cond: string = core.getInput('cond', {required: true}) - const ifTrue: string = core.getInput('if_true', {required: true}) - const ifFalse: string = core.getInput('if_false', {required: true}) + const ifTrue: string = core.getInput('if_true') + const ifFalse: string = core.getInput('if_false') core.setOutput('value', cond === 'true' ? ifTrue : ifFalse) } catch (error) { core.setFailed(error.message)