Skip to content

Commit

Permalink
feat: Validate inputs that cannot be used together
Browse files Browse the repository at this point in the history
  • Loading branch information
M1kep committed May 30, 2022
1 parent 9662f5c commit 660601a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions main.js
Expand Up @@ -31,6 +31,29 @@ async function main() {

console.log("==> Conclusion:", workflowConclusion)

const uniqueInputSets = [
{
"pr": pr,
"commit": commit,
"branch": branch,
"run_id": runID
},
{
"workflow_conclusion": workflowConclusion,
"run_id": runID
}
]
uniqueInputSets.forEach((inputSet) => {
const occurrences = Object.values(inputSet).reduce((occurrences, val) => {
if (val !== '') {
return occurrences++
}
},0)
if(occurrences > 1) {
throw new Error(`The following inputs cannot be used together: ${Object.keys(inputSet).join(", ")}`)
}
})

if (pr) {
console.log("==> PR:", pr)

Expand Down

0 comments on commit 660601a

Please sign in to comment.