Skip to content

Commit

Permalink
Validate inputs that cannot be used together (#160)
Browse files Browse the repository at this point in the history
* feat: Validate inputs that cannot be used together

* Fix reduce callback

* Simplify inputSet validation
  • Loading branch information
M1kep committed Jun 5, 2022
1 parent b7337e5 commit 27fee4d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.js
Expand Up @@ -36,6 +36,22 @@ async function main() {
core.info(`==> Repository: ${owner}/${repo}`)
core.info(`==> Workflow conclusion: ${workflowConclusion}`)

const uniqueInputSets = [
{
"pr": pr,
"commit": commit,
"branch": branch,
"run_id": runID
}
]
uniqueInputSets.forEach((inputSet) => {
const inputs = Object.values(inputSet)
const providedInputs = inputs.filter(input => input !== '')
if (providedInputs.length > 1) {
throw new Error(`The following inputs cannot be used together: ${Object.keys(inputSet).join(", ")}`)
}
})

if (pr) {
core.info(`==> PR: ${pr}`)
const pull = await client.pulls.get({
Expand Down

0 comments on commit 27fee4d

Please sign in to comment.