Skip to content

Commit daa593b

Browse files
committed
Allow disabling commit and push
1 parent 5f12849 commit daa593b

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
branch:
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
26+
push:
27+
description: "Whether to push the new commit back to the repository. Default: true"
28+
required: false
2629
runs:
2730
using: "node12"
2831
main: "index.js"

src/index.jsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,21 @@ const main = async () => {
6767
return
6868
}
6969

70-
await exec('git', ['commit', '-m', commitMessage])
71-
72-
if (doesBranchExist) {
73-
await exec('git', ['push'])
74-
} else {
75-
await exec('git', ['push', '--set-upstream', 'origin', branch])
76-
}
70+
const shouldPush = getAsBoolean(core.getInput('push'), true)
71+
if (shouldPush) {
72+
core.startGroup('Commit and push diagram')
73+
await exec('git', ['commit', '-m', commitMessage])
74+
75+
if (doesBranchExist) {
76+
await exec('git', ['push'])
77+
} else {
78+
await exec('git', ['push', '--set-upstream', 'origin', branch])
79+
}
7780

78-
if (branch) {
79-
await exec('git', 'checkout', '-')
81+
if (branch) {
82+
await exec('git', 'checkout', '-')
83+
}
84+
core.endGroup()
8085
}
8186

8287
console.log("All set!")
@@ -106,3 +111,7 @@ function execWithOutput(command, args) {
106111
}
107112
})
108113
}
114+
115+
function getAsBoolean(option, defaultValue) {
116+
return option === '' ? defaultValue : (option.toLowerCase() === 'true')
117+
}

0 commit comments

Comments
 (0)