Skip to content

Commit afab037

Browse files
committed
Simplify boolean inputs
1 parent bed9482 commit afab037

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ inputs:
2424
description: "The branch name to push the diagram to (branch will be created if it does not yet exist). For example: diagram"
2525
required: false
2626
push:
27-
description: "Whether to push the new commit back to the repository. Default: true"
27+
description: "Whether to push the new commit back to the repository. Must be true or false. Default: true"
2828
required: false
29+
default: true
2930
upload:
30-
description: "Whether to upload the new diagram as an artiface. Default: false"
31+
description: "Whether to upload the new diagram as an artiface. Must be true or false. Default: false"
3132
required: false
33+
default: false
3234
runs:
3335
using: "node12"
3436
main: "index.js"

src/index.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const main = async () => {
6868
return
6969
}
7070

71-
const shouldPush = getAsBoolean(core.getInput('push'), true)
71+
const shouldPush = core.getBooleanInput('push')
7272
if (shouldPush) {
7373
core.startGroup('Commit and push diagram')
7474
await exec('git', ['commit', '-m', commitMessage])
@@ -85,7 +85,7 @@ const main = async () => {
8585
core.endGroup()
8686
}
8787

88-
const shouldUpload = getAsBoolean(core.getInput('upload'), false)
88+
const shouldUpload = core.getBooleanInput('upload')
8989
if (shouldUpload) {
9090
core.startGroup('Upload diagram to artifacts')
9191
const client = artifact.create()
@@ -125,7 +125,3 @@ function execWithOutput(command, args) {
125125
}
126126
})
127127
}
128-
129-
function getAsBoolean(option, defaultValue) {
130-
return option === '' ? defaultValue : (option.toLowerCase() === 'true')
131-
}

0 commit comments

Comments
 (0)